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
Related
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()
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.
http://developer.android.com/reference/java/util/Locale.html
What is the difference for example between
Locale FRENCH vs Locale FRANCE
and
Locale GERMAN vs Locale GERMANY
I am searching, but I can't find the anything about the difference in the documentation. Any idea?
French and German are spoken in more countries than just France and Germany. In different countries they will have different currencies, different ways of writing numbers, etc. That's why you can indicate both the language & region of your locale, and that's why you can define specific resources for each language/region-combination (e.g. de-DE for Germany vs de-AT for Austria, or fr-FR for France vs fr-rCA for Canada).
One refers to a geographic area (and its conventions, such as using commas or decimal points in numbers), the other to a language.
For example, French could be spoken in France or Canada.
A Locale contains:
language code
country or region code (optional)
optional variant code (optional)
Therefore there are multiple predefined Locale objects for the same language. Some with Countrycode and some just with the language.
See: java.sun.com/developer/technicalArticles/J2SE/locale for more details
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.
What languages are supported by android for localization with their respective values folder name, the best link i could find was http://developer.android.com/reference/java/util/Locale.html
any body can help me with more languages what if we need to support more languages then listed above.
My app uses the following undocumented languages, and they work:
ca Catalan
el Greek
es Spanish
pl Polish
pt Portuguese
ro Romanian
ru Russian
sv Swedish
More generally, it should be the string in the "639-1" column of this table.
I suggest use the list of the ISO 639-1 standard
Virtually any language defined by the Strings representing the language code (as specified by ISO 639-1) and (optionally) country (as defined by Alpha 2 representation of ISO 3166-1). You can specify only the language (i.e. "en") or the language used specifically in one area (i.e. "en","US"). You do not need to use the constants (though convenient) that come with Locale.
// This is to get spanish locale of Spain
Locale spanish = new Locale("es", "ES");
The problem is not only specifying the correct languages, but also assuring that the mobile phone supports literals/formatting for the indicated Locale. I.e. a mobile phone sold in Spain will support "es" and "es_ES", almost surely "en" and "en_US" too and probably "ca_ES", "ba_ES" and "gl_ES". It is not likely that it will support for example "es_AR" or "zh_CN". So I think that the answer to your question is "it depends on the market of your application".