Android Multiple Language Support Example


This is one among the reason why android warns you about hardcoded labels in your application. If you want your application to support multiple languages or to be set to the device language the strings.xml file in the values folder is the one you should look for.

By default android sets your application language to English. If you want your application to support another language say French. All you have to do is to create a folder named ‘values-fr’ under ‘res’ folder and place the ‘strings.xml’ (like the path res/values-fr/strings.xml)
Create the stings.xml file in res/values/strings.xml as

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My Application</string>
<string name="hello">Hello World, This is a language test application</string>
<string name="textview">This is a textview</string>
<string name="editview">This is a editview</string>
<string name="button">This is a button</string>
</resources>

Create the stings.xml file in res/values-fr/strings.xml as

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mon application</string>
<string name="hello">Bonjour tout le monde, Il s\'agit d\'une application de test de langue</string>
<string name="textview">Il s\'agit d\'une textview</string>
<string name="editview">Il s\'agit d\'une editview</string>
<string name="button">Il s\'agit d\'un bouton</string>
</resources>

Now run the application and your activity would look like



Now change the device language to french and the same activity would look like