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
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 translate my apps to Portuguese language. After users asking for Portuguese translation despite it's already translated, i can see it's translated when i change my device's language to Portuguese, i thought maybe i need to pt-rBR folder, but it does not help either.
I asked users to send their device language, image or screenshot of the app, but after multiple tries and few weeks none of them replied back.
Does anyone experience the same issue with Portuguese? I really can't figure out why it happens, i tried on 3 devices and both work fine. I also translated to Spanish, and Spanish is spoken in various countries too, haven't got any issues.
All the Portuguese strings (works for other resources too) should go to values-pt/strings.xml you should only use values-pt-rPT and values-pt-rBR if you have specific localizations for Portugal and Brazil respectively, otherwise (and in terms of simple localizations) they should share most elements.
Spanish is the same, you have values-es and then values-es-rES for Spain specifically, but various other Spanish-speaking countries, e.g.: values-es-rAR for Argentina and so forth.
French: values-fr or values-fr-rCA for Canada, etc.
Source: https://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
The language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r").
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
In the below link the documentation mentions creating "res/values-fr/strings.xml" for French translations and "res/values-ja/strings.xml" for Japanese translations. However, I couldn't find a list of all the acceptable path formats for all languages. I assume Italian would be "res/values-it/strings.xml", but it would be great if someone knew where this is documented.
http://developer.android.com/guide/topics/resources/localization.html
I assume Italian would be "res/values-it/strings.xml"
Yes, it is. The resource system uses the ISO3166-1 two letter country codes. See TelephonyManager.
Taken from Android docs:
The language codes are two-letter lowercase ISO language codes (such as "en") as defined by ISO 639-1. The country codes are two-letter uppercase ISO country codes (such as "US") as defined by ISO 3166-1.
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".