I have a bunch of localized strings.xml files as good located in values-XX folders.
Definetely, I know how to localize my app dependently from phone language settings. It is easy, right? Just change phone language settings, and Android will takestrings.xml linked to picked language.
In my case I should to allow to user pick preferable language, in application settings.
So, I want to know. Is it possible to keep my current R.string.<anything> everywhere, is it possible to say to Android : "hey! I need to use strings.xml from values-EN folder (for example)?"
Related
I'm working on localizing an Android app.
For arguments sake, let's say the app will support English, Albanian, and Bengali.
Currently all English strings are listed in the "default value" column of the translations editor:
Apps on the app store generally state what locales they support.
I'm assuming when you submit an app that either a person or machine verifies your claims... so...
Is it necessary to explicitly add English (en) locale/column in addition to the default values (just as Albanian and Bengali have been added in the photo) in order for the app to be considered to officially "support" English?
You do not have to add English locale to have it in Supported Language menu. Check documentations out.
When your Java code refers to strings, the system would load strings from the default (en_US) resource file, even if the app has Spanish resources localized under es_ES. This is because when the system cannot find an exact match, it continues to look for resources by stripping the country code off the locale. Finally, if no match is found, the system falls back to the default, which is en_US.
The system would also default to en_US if the user chose a language that the app didn't support at all, like French.
Default locale is en_US.
No.
Apps on the app store generally state what locales they support.
If you are talking about Apple's App Store, Google Play won't list the supported languages in similar fashion.
However, you can localize the store listing page. According to play console help, If a user's language preference matches the translation languages you've added, they'll see your app's translated version. You can also add localized graphic assets for your store listing pages. See this for more. This feature is similar to App Store's metadata localization.
There is an easy solution to your problem.
Just find the path in your project:
res/
and add a folder named:
values-en
Then add a file named:
strings.xml
Finally, it will look like this:
res/values-en/strings.xml
And the resources in it will show when the user's language setting is English.
Within my app, I let user change the language when they install the app. Lets say they choose "English" while installing the app. But after that if they change the language of the phone to "French" how should my app receive it and change its language?
Assuming you use strings.xml to manage your string resources, Android natively supports localization:
https://developer.android.com/preview/features/multilingual-support.html
The idea is that you have distinct strings and values for each language you want to manage, then when the user changes the language in settings the app will automatically choose the correct file (or fall back to the default strings.xml if you haven't defined resources for the chosen language).
The app will automatically load its respective language strings files from the res/values directory after the application restarts. You could persist and compare Locale.getDefault().getLanguage() to check if the language has changed since the last restart.
It will try to get information about french in values (value-fr) if you didnt add the translations it will keep showing english
I have placed the resources to support different languages in appropriate packages as suggested in Android Localization documentation. Is there a way to add additional languages, i.e, resources after the app is installed without having to download and re-install the app. I mean updating the app - adding new resources and even updating some existing ones.
For example if my app initially supported English and French. Now suppose I want to add new language say Hindi and update few of the resources in English. So what is the approach..?
I had this issue, my approach is to create separate folder on the device \data\packageName\languages\
there will be one file called supportedfiles.lang the format of the file will be
English en
Russian ru
...
also in same location you will have the following files
en.lang
ru.lang
the format of each language file ie(en.lang / ru.lang) will be like regular strings.xml
Some text
when you load the application in settings screen you will read the supportedfiles.lang and show to user the supported languages when he choose different language you just need to load the appropriate language file
Maybe it is over kill, but you will have the flexibility to support other languages while the application installed without updating the application just copy the files into /data/package/languages/
I am trying to localize my app and have a few doubts. i have translate strings in spanish language and i am trying to be very specific with Region codes, so I named the folders as values-es_rES, values-es_rUS and values-es_rMX. Now there are more countries and users who like to use spanish language so i created a generic values-es folder.
I am wondering can android automatically push all mexico, US and Spain users to respective languages under their region codes and can others like chile, peru will be shown values-es language rather than my default US English?
You have two options
Use the language-region locale (ie. es_ES for Spanish/Spain or es_PE for Spanish/Peru)
Use MNC/MCC codes in your resource folders, which will take presence over the locale ones.
The way you have described it, all users with a defined locale of es_XX (any region) will go to your "values-es" folder, but the US user will not, unless the US user has configured "es_US" as their locale.
Take a look at Table 2 at
http://developer.android.com/guide/topics/resources/providing-resources.html
Remember that if an asset is missing from "es_ES" it will get it from "es", so only change those that are different.
in my case the application will be installed on a single device and will be used by different users to login and use the app, problem here is that the users are of different languages you can say some are of french language and some are English language so i decided to do this by putting two strings.xml files, one in "Values-fr" for french ones and one in "Values" means if the person is french then use french resources otherwise default will be English resources. as this will not work because device is single and it'll be irritating if french one have to change device language to french to see app in french and then when English user came he needs again to change the device local language to English to see app in English. so language prefrences are stored in database for each user. i just want here that the selection of localized resources i.e the selection between "Values" and "Values-fr" should be done by my decision not by android deciding on the basis of device local language. is this possible?
You can try changing the locale from within the app so that the proper values are assigned and restore it when quitting. This is rather a crude solution to your problem.
This link could be useful in your quest.