Translate a string

suggest change

Strings can be internationalised by defining a different strings.xml for each language you support.

You add a new language by creating a new values directory with the ISO language code as a suffix. For example, when adding a German set your structure might look like follows:

When the system looks for the requested string it first checks the language-specific xml, if it is not found, the value from the default strings.xml file is returned. The key remains the same for each language and only the value changes.

Example contents:

/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">HelloWorld</string>
    <string name="hello_world">Hello World!</string>
</resources>

/res/values-fr/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello_world">Bonjour tout le monde !!!</string>
</resources>

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents