Make use of simple multilanguage support
by Martin on Mar.06, 2009, under how to
In our little sample application we used the strings.xml to define static texts.
If you want to use the build-in multi-language support you just have to follow some easy conventions.
To use localization for strings you have to add a new directory to res/ and name it “values-de” for the german language.
Create a strings.xml in this directory and deploy your application. If you now change your language on the device or emulator, the phone picks the strings.xml with the matching local code and uses it – in the same manner you could provide images etc. for a specific language (i.e. graphical buttons).
Works well for our little sample.
Our strings.xml for the german language:
1 2 3 4 5 6 7 8 | <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Wähle einen Freund</string> <string name="button_info_text">Bitte wähle einen Kontakt aus</string> <string name="button_text">Auswahl</string> <string name="contacts">Kontakte</string> <string name="chosen">Sie haben ausgewählt:</string> </resources> |
September 16th, 2009 on 7:40 am
Hi,Martin
should i save two file for the String.xml,
one for English,another for German?
September 16th, 2009 on 9:12 am
Yes you should.
You can mix different languages in one file and check progrmmatically which language you should use but this isn’t the best practice.
Also you should at least deploy your app supporting english to reach more users.
September 23rd, 2009 on 2:29 pm
I don’t know if it changed due to the release of SDK 1.6 or if you just forgot the s but it’s values-de instead of value-de
Rgds
Coil
December 12th, 2009 on 1:52 pm
Thanks a lot for your great article man
January 6th, 2010 on 11:18 am
how to change text view to the specified language??
January 6th, 2010 on 12:10 pm
The language will be automatically changed by android.
If there is no matching directory for the language used by the device, the default “values” directory will be used.
January 21st, 2010 on 1:03 pm
ok thnx for ur reply Martin
February 5th, 2010 on 9:52 am
I have some Images with dialogs.
How do I implicate multilanguage images?
February 5th, 2010 on 10:06 am
Afaik the directory extension should work for the drawable too. Try a second drawable directory with the language suffix like the example above.