-
Notifications
You must be signed in to change notification settings - Fork 0
Locales and Android Support
Android supports only a subset of the locales found in Java's Locale API, which uses the BCP47 spec for its language tags. However, Android uses a slight variation of the spec as seen below.
It is not always clear which language tags will compile with each formatting when adding them as resourceConfigurations
and may require some experimentation.
xx-Yyyy-ZZ
- xx = country code
- Yyyy = script code
- ZZ = region code
Script and region codes are optional, and the following examples are all correct.
tag | locale |
---|---|
es |
español |
fr-CH |
français (Suisse) |
sr-Latn |
srpski (latinica) |
az-Cyrl-AZ |
азәрбајҹан (Кирил,Азәрбајҹан) |
It seems Android generally doesn't support script codes in resourceConfigurations
language tags, with one known exception below. This is possibly due to the need for the language tags to align with localized build resources, which were implemented differently (speculation). Most supported tags can be converted from 'Java dash' to this '-r' format.
xx-rZZ
- xx = country code
- r = resource (maybe?)
- ZZ = region code
Region codes are generally optional, but some tags will fail to compile with only the country code.
tag | locale |
---|---|
es |
español |
fr-rCH |
français (Suisse) |
sr-Latn |
srpski (latinica) |
az-Cyrl-AZ |
doesn't compile |
Android also has its own variation of some language tags that do not appear in the Locale API.
tag | locale |
---|---|
zh |
中文 |
zh-rCN |
中文 (中国) |
zh-rTW |
中文 (台灣) |
Another supported variation is the 'b+' format Android uses for locale resolution since API level 24. Some experimentation may be needed to determine if a resourceConfigurations
will compile with 'b+' or '-r' formatting.
tag | locale |
---|---|
b+de+DE |
Deutsch (Deutschland) |
b+es |
español |
b+fr+CH |
français (Suisse) |
b+sr+Latn |
srpski (latinica) |