j2emanue
j2emanue

Reputation: 62519

Android localization - How to use values folder -b qualifier

android resources folder values. What is the values**-b** option i read about here?

What i want to do is have my app support two different languages, french and spanish. But i had a thought. it would be much more organized if instead of doing strings-es.xml and strings-fr.xml if i could do this:

values-es
     |
    Strings.xml

values-fr
     |
    Strings.xml

this way if there is any other things that should be localized they can easily go into the respective folders. Is this possible ?

Upvotes: 5

Views: 1882

Answers (2)

Liggliluff
Liggliluff

Reputation: 756

The synax of -b+ allows you to include the script of the language, for languages that use multiple script like Serbian, whilst the old method don't allow this.

The default format that Android uses (as of 7.1) is as following:
values-sr is Serbian in the Cyrillic script
values-b+sr+Latn is Serbian in the Latin script

It is known as a BCP 47 language tag. BCP 47 documentation

Upvotes: 6

ThomasW
ThomasW

Reputation: 17317

Using '-b' is a newer way of supporting locales. You can support locales using the method you indicate above, but you can also support locales by putting them in directories like this:

values-b+es/strings.xml
values-b+fr/strings.xml

Upvotes: 3

Related Questions