I'm developing a multi-language PhoneGap app and would like to store the user's language preference. On first launch of the app a splash screen would come up with 4 flags, user picks, and then is directed to a landing page in that language. From then on the app load skips the splash screen and goes straight to the landing page in the preferred language. Easy to do? Suggestions? I'm familiar with cookies/local storage but if anyone has done this before I would appreciate specific directions. Thanks.
LocalStorage. Local storage provides simple, synchronous key/value pair storage, and is supported by the underlying WebView implementations on all Cordova platforms.
Apache Cordova Is Retired: Alternatives for Cross Platform Mobile Development in 2022. Future trends of cross-platform mobile development are already starting to emerge, and it appears that Apache Cordova won't be included in the list of frameworks that power hybrid web apps for mobile devices.
PhoneGap is one such platform which we specialize in. What is PhoneGap? PhoneGap is an emerging open source mobile application development platform best suited for cross-platform compliant mobile applications. Developed by Apache Software Foundation, PhoneGap is also known as Apache Cordova.
What you describe should be very easy to do with localStorage. I researched it before using it on Android, and found this webpage to have very helpful code examples and explanations. Very short and sweet.
To save to local storage use:
function saveLanuageID(languageID)
window.localStorage.setItem('lang', languageID);
Read from local storage
function readLanguageID(){
if (typeof window.localStorage.getItem('lang')!== 'undefined' && window.localStorage.getItem('lang')!=null) {
return window.localStorage.getItem('lang');
}
else return false
}
You would have to test for saved language using the code above
if(!readLanguageID())
//redirect to splash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With