How to set different locales in android

– create new folder with values in resources folder in project with extension your language code
For example:
My language is Czech (cs)
I have to create the folder values-cs in res folder

// for locale English is default
<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">App English default</string>
    <string name="action_settings">Settings English default</string>
    <string name="hello_world">Hello world</string>
// for locale Czech (cs)
<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">Aplikace česky cs</string>
    <string name="action_settings">Nastavení česky</string>
    <string name="hello_world">Ahoj světe!</string>
// for locale English US (r is region)
<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">App English Us locale</string>
    <string name="action_settings">Settings English Us locale</string>
    <string name="hello_world">Hello world from USA :)</string>

Into every values folder put strings.xml file
Translate every string from values folder into your locale.
If user selected your locale in device settings, application selects a string from the correct (proper) folder.

This entry was posted in Android Examples Code and tagged , . Bookmark the permalink.

Comments are closed.