Reputation: 3127
I am trying to localise strings to es_US (Spanish in US).
I have string resources in folder values-es-rUS and language on device is set to Español (Estados Unidos), Locale.getDefault()
returns es_US
.
Even when everything seems to be correct, app doesn't pick up strings from values-es-rUS but it falls to values.
Did someone make it work?
EDIT: Solved. Can't mark my answer as accepted now.
Upvotes: 1
Views: 1728
Reputation: 26961
res/values-es_rUS
strings.xml
files must have same names in all strings localized
*From here (table 2 - section 2)
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").
The codes are not case-sensitive; the r prefix is used to distinguish the region portion. You cannot specify a region alone.
This can change during the life of your application if the user changes his or her language in the system settings. See Handling Runtime Changes for information about how this can affect your application during runtime.
See Localization for a complete guide to localizing your application for other languages.
Also see the locale configuration field, which indicates the current locale.
Upvotes: 1
Reputation: 3127
Problem was in gradle build file configuration. I use resConfigs "en", "es" so build can exclude other resources. It seems that "es" excludes also "es_US".
When I changed it to resConfigs "en", "es_US" it started to work
Upvotes: 2
Reputation: 1600
http://developer.android.com/guide/topics/resources/localization.html
I'm sure you've looked at this, but it has everything you need on it. I followed the instructions step by step and was able to localize my strings. Perhaps you named your values folder incorrectly? That would be my guess
Upvotes: 0