On an android device I can load different languages.
Example:
English (Set as default language)
French
Italian
How can I get this list programmatically?
I know that I can get the language with this code:
Locale.getDefault().getDisplayLanguage()
Or is there a way to set the fallback language of my android app to the second language of the system?
EDIT://
Szenario:
Selected Android System Languages:
English (Set as default)
French
Italian
Supported App Languages:
string.xml (German) -> set as default
string-fr.xml (French)
string-it.xml (Italian)
Current App behavior:
Displays the app with the German translation.
Expected new App behavior:
Displays the app with the French translation because French is on the 2nd position in my Android System Language list.
This will return all locales available on the device.
Locale.getAvailableLocales()
Related
The default language for my android app is English and the respective strings are stored in the default /res/values/strings/strings.xml
Now I wanted to support the french language so I opened the Translation Editor and added the translations for French (fr) locale.
But there seems to be multiple locale variants of french language(i.e. French in Algeria, French in Belgium ... etc) and I didn't added the translations for all these.
I just wanted to know, what language is shown to the users who has French as the default language on their devices but with a specific locale for which I don't have the specific translations.
When a user has a more specific locale specified than the app does, then the localization should "fall back" to basic language definition, in your case, "fr."
You can test these things in a simulator.
As you know, this already happens with English, your default language... and you weren't worried about what happens if someone is set to en-GB, or en-AU.
i.e. If a device is running in a particular language (Say Spanish) then how can I set the Spanish language(After translation) as the default language of the app without asking the user.
The app should initialize in the Spanish language in this case while installation and a user should be able to change the language from the setting page of the app.
You need to add all string.xml files in specific language values folder.
So when your user change mobile default language your app may take string values from that particular language values strings.xml file.
By Locale, you can get a currently selected language of a device. Please have a look below code to get the language.
Locale.getDefault().getDisplayLanguage();
I want my android app to display chinese (using the zh-rTW strings) when the device is in zh_TW and display the default language (english in this case) for zh_HK. Is that possible?
I am testing on Android 7.1.1, only 1 locale in the setting: zh_HK. The app has multiple strings.xml, which contains zh_rTW. When I open the app, I can see everything in zh.
if only for display you can take the locale "zh_HK" and change it to "en_US" whenever someone choose this language or your device change it.I think it is the same way you create a button that changes the language. You take the default locale and change it to the one you want.If i understood the question correct.
In the Setting application, when choosing Language & keypad then Select a language, I find a list of many languages (English, French, Japanese, ...) about 30 languages. But I only want to find about 10 languages of my choice. In the Language setting application, I found this code :
String[] locales = getAssets().getLocales();
I think this code brings the locale from android internal class. So how to modify it to only bring locales that I want ( English, French, Spanish ...)
Thanks
I would like to set my emulator locale to some custom locale for Indian regional languages like Tamil or Kanada or telugu. Any one plz give suggestions, Thanks in Advance.
you must download your language font file(.ttf). after,import font file in your project assets folder create folder fonts and paste your font file(.ttf) to folder fonts.
after following instructions in below link for stack overflow post :
Android Tamil font between english word
(or)
Refer this document
http://developer.android.com/training/basics/supporting-devices/languages.html
iso code for all languages link below
http://www.w3.org/WAI/ER/IG/ert/iso639.htm
Welcome...!
It is my fault not clearly understanding android documentation link given below
http://developer.android.com/guide/topics/resources/localization.html
For others sake,
Creating and using a custom locale is for developers to test localization apps in android emulator.There are two ways to create custom locale for more see above link.
* Use the Custom Locale application, which is accessible from the Application tab. (After you create a custom locale, switch to it by pressing and holding the locale name.) In my case I given te_IN for telugu(Indian) locale.
* Change to a custom locale from the adb shell
I am just confused by checking custom locale app in device.
Also, Right now there is no default locale support for Indian regional languages except for Hindi, for which code is hi_IN, that too in Android 4.0.3. So even though we set Custom locale to telugu Indian i.e te_IN, Android system will not identify telugu fonts. Any suggestions on this? I want this on Android 2.2 version.