Introduction
The next step in development Android application will be localization. I’ve read documentation from official site and from http://www.icanlocalize.com/ and decided to describe it.
Sequence of resources lookup
How does android lookup the resources from applications?
The example of lookup steps below:
- ‘res/values-en-rUS/strings.xml’
- ‘res/values-en/strings.xml’
- ‘res/values/strings.xml’
Firsltly Android looks for resources in en-rUS folder if not found, looks in -en folder and just after it in default. If resource has been found then the search stops.
Dismantle folders structure
The next question that worried me : What does it mean -rUS why is not just en?
The answer is, There are countries with two or more official languages for example Switzerland but there is no Swiss language just French or/and German. The fisrt -<symbol>- (in our example -en-) means language, -r means region and after -r name of region. For instance for French language in Switzerland will be
res/values-fr-rCH
This rules works for other resources like pictures and so on.
Conclusion
If you want to localize your application just:
- create folders for all localized resources using above convention
- put localized files into folders
- start your application
P.S. And yes you must not to use strings in code just from resource files.
And that is all …
Cheers!