As we know already e.g. we cannot change res
folder values and files at runtime,
I am working on an app, in which we are supporting more than 25 languag
Here Sqlite Option is better for your condition .
Following is the structure of data base table (eg. LangTable)
--------- ---------- -------- -------- --------- -------
langKey Locale_En Local_hn Local_Fr.......................n
---------- ---------- --------- -------- ------ ------- ---
btnOk ok ..... ...... ..........
btnCancel cancel ......... .... .... .......
Now here is method for get Relevant local string
public String getResource(String key, String local){
String value = "";
value = Select local from LangTable where langKey = 'key';
return value;
}
Do you know about Android App Bundle? it is a new way to publish your app to Google Play, and you don't need to refactor your code to use it, and you downloaded apk from Play Store will be more small?
From Google Developers:
The new app publishing format, the Android App Bundle, is a more efficient way to build and release your app. The Android App Bundle lets you more easily deliver a great experience in a smaller app size, allowing for the huge variety of Android devices available today. It's easy to switch. You don’t need to refactor your code to start benefiting from a smaller app.
Available in Android Studio 3.2 or later and the Unity 2018.3 beta release.
So if your project have 25 languages and my device have configured English as the device language, when I go to download your APP it will get only the strings.xml
file the others strings.xml
remain in Google Play, and if you change your device language to Portuguese, Google Play App will try to get the new strings.xml
for Portuguese and delete the old file with English text.
Please before you try another option try this first as it is the recommended way and you do not need to do anything else, just generate your app as App Bundle and send to Play Store and if you want to test, download your app then change the device language you will see Google Play downloading the app's new language again.
Hope I helped you anyway.
this can be achieved with the help of AppBundle feature of google play. one of his jobs is to allow other parts app (string res) to be downloaded later when user need them or when you decide.
there's also a bad approach too! you can ignore getString()
completely and write a method that retrieves the strings from a different location (like the downloaded file)
I suggest you follow the AppBundle approach which is reasonable and you don't have to fight the OS.
Unfortunatelly resources couldn't be changed after compilation. The only way for you is to download language shema from server (i.e when app starts) and save it (or update if needed) in sqlite, file or in shared preferences (the storage options: https://developer.android.com/guide/topics/data/data-storage.html#filesInternal).