Android localize es-r419
Asked Answered
F

4

21

I'm localizing my app and one of the language/region supported is Espanol-419. Android doesn't support the naming convention values-es-r419 but it does accept values-en-rGB. What name should I use to make it work?

Frangipane answered 20/1, 2012 at 5:52 Comment(0)
T
16

I don't know where r419 comes from. The only thing I could think that it would be is an LCID but 419 is for Russian, or a country code, but there's nothing for 419. Here are a list of locale codes for Spanish, perhaps the one you want is in here:

es-ar  Spanish - Argentina
es-bo  Spanish - Bolivia    
es-cl  Spanish - Chile
es-co  Spanish - Colombia
es-cr  Spanish - Costa Rica
es-cu  Spanish - Cuba
es-do  Spanish - Dominican Republic
es-ec  Spanish - Ecuador
es-sv  Spanish - El Salvador
es-gt  Spanish - Guatemala
es-hn  Spanish - Honduras
es-mx  Spanish - Mexico
es-ni  Spanish - Nicaragua
es-pa  Spanish - Panama
es-py  Spanish - Paraguay
es-pe  Spanish - Peru
es-pr  Spanish - Puerto Rico
es-es  Spanish - Spain (Traditional)
es-uy  Spanish - Uruguay
es-ve  Spanish - Venezuela

References:

Update:

So apparently 419 is from the UN M.49 standard taken up by BCP 47 for the IETF language tag. Google's documentation on alternative resources says:

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").

Clearly (by the "r" alone) you can see that these are not standard IETF language tags. Unfortunately, I believe this also means that you won't be able to find a suitable two letter region equivalent to 419. You can also check the official ISO list. It's not on there, there are only two letter tags for countries. Apparently it's very common not to support the 3-digit tags.

The only solution I can think of is to provide a default set for es and then a more specific set for a subdivision of es countries. You could provide resources for each region (like es-rAR) that you think matches up with 419, but looking at that list, I think it'd be easier to do the opposite and use es to provide resources for Latin American Spanish, and then provide resources for es-rES for Spain. As es-rES is more specific than es, it should take precedence (if the locale matches).

Tuttle answered 20/1, 2012 at 6:31 Comment(4)
Updated with what is hopefully a solution.Tuttle
so just to clarify, if you only provide an es package, it will be chosen for all es qualifiers if you don't specify a more specific one?Hypothyroidism
419 is used in iOS, not in Android.Aliment
Play Console itself supports es-419 - see support.google.com/googleplay/android-developer/table/4419860Hildegaard
A
11
es-r419 = es-rUS. 

change the folder name to values-es-rUS for consistency with runtime user options.

When using Google Translation services, when you request translation to Spanish for Latin America, you will receive es-r419 folder returned.

When looking at AOSP source, or in the settings->language and input->language, you will see Spanish and Spanish (United States).

At runtime, selecting language = Spanish (United States), you will not see strings pulled from values-es-r419, and of course you will see strings pulled from values-es-rUS

Alienate answered 29/10, 2014 at 20:18 Comment(1)
More locales for Spanish are available than just es-rUS, and according to jt-gilkeson, you can, in Android 7.0 and later, write b+es+419 to access these UN M.49 regions.Tonsillotomy
A
10

Android 7.0 (API level 24) brings more robust resource resolution, and finds better fallbacks automatically. However, to speed up resolution and improve maintainability, you should store resources in the most common parent dialect. For example, if you were storing Spanish resources in the values-es-rUS directory before, move them into the values-b+es+419 directory, which contains Latin American Spanish.

Source: https://developer.android.com/guide/topics/resources/multilingual-support.html

We offered language selection in-app, so to work well on new and old phones we kept duplicate resources in values-es-rUS Español (Estados Unidos) as well as values-b+es+419 Español (Latinoamérica)

Anodyne answered 16/2, 2017 at 19:3 Comment(2)
I think this should be the new accepted solution because it's based on the latest information from Google (developer.android.com/guide/topics/resources/…).Acus
Indeed this is the new correct answer. I've tested it with Android Studio 3.5 and it recognizes the values-b+es+419 language tag correctly.Sunnisunnite
M
0

419 comes from here, and is for any LatinoAmérica (Spanish) regions.

Español (Colombia), Español (México), etc, will use values-es-r419

We can also use this for each region instead of names, although it is more difficult

values-en-r840 intead of values-en-rUS

But, if we want a language for each region, the file must have the language followed by "-r" and the country code. The name is added automatically when choosing the region.

To do that, create a "value resource file", choose the "Locale" option and choose the region.

enter image description here

If the device language is "English (United States)" will take values-en-rUS/strings.xml.

If the device has a language with a country that we do not support, will use values-en/strings.xml (is used by any region).

Now, if you want to programmatically add the language, you cannot set the language as "en_US" or "en-rUS" because it doesn't exists, "en_US" is still "en". That's why you need to add the country to the Locale language (android supports upper or lower case)

//Example language = "en" country = "US"
private void setLanguage(Context context, String language, String country) {
    Configuration config = new Configuration(context.getResources().getConfiguration());
    config.setLocale(new Locale(language, country));

    //Copies the fields from delta into this Configuration object, keeping track of which ones have changed.
    config.updateFrom(new Resources(context.getResources().getAssets(),
            context.getResources().getDisplayMetrics(), config).getConfiguration());

    context.createConfigurationContext(config);
}
Mcpherson answered 23/12, 2019 at 17:16 Comment(1)
Outdated information. Nowadays you would use values-b+es+419 for Latin American Spanish, which will be the root regardless of which Spanish country you pick for Latin America. You can then further specify regional differences with values-es-rAR if Argentina has differences from the rest of Latin America.Tonsillotomy

© 2022 - 2024 — McMap. All rights reserved.