Android Localization

An android application can run on many devices in many different regions. In order to make your application more interactive, your application should handle text,numbers,files e.t.c in ways appropriate to the locales where your application will be used.

> The way of changing string into different languages is called as localization

In this chapter we will explain , how you can localize your application according to different regions e.t.c. We will localize the strings used in the application, and in the same way other things can be localized.

Localizing Strings
In order to localize the strings used in your application , make a new folder under res with name of values-local where local would be the replaced with the region.

For example, in the case of italy, the values-it folder would be made under res. It is shown in the image below −

Once that folder is made, copy the strings.xmlfrom default folder to the folder you have created. And change its contents. For example, i have changed the value of hello_world string.

Italy, res/values-it/strings.xml

Ciao mondo!

Spanish, res/values-it/strings.xml

Hola Mundo!

French, res/values-it/strings.xml

Bonjour le monde !

Apart from these languages, the region code of other languages have been given in the table below −

Sr.NoLanguage & code1Afrikanns

Code: af. Folder name: values-af

2Arabic

Code: ar. Folder name: values-ar

3Bengali

Code: bn. Folder name: values-bn

4Czech

Code: cs. Folder name: values-cs

5Chinese

Code: zh. Folder name: values-zh

6German

Code: de. Folder name: values-de

7French

Code: fr. Folder name: values-fr

8Japanese

Code: ja. Folder name: values-ja

Example
To experiment with this example , you can run this on an actual device or in an emulator.

StepsDescription1You will use Android studio to create an Android application under a package com.example.sairamkrishna.myapplication.2Modify the res/layout/activity_main to add respective XML components3Modify the res/values/string.xml to add necessary string components4Run the application and choose a running android device and install the application on it and verify the resultsFollowing is the modified content of the xml res/layout/activity_main.xml.

Following is the content of the res/values/string.xml.

My Application
Hello world!
Settings
ట్యుటోరియల్స్ పాయింట్
शिकवण्या बिंदू
نقطة الدروس7
教程点

Let’s try to run our application we just modified. I assume you had created your AVD while doing environment setup. To run the app from Android studio, open one of your project’s activity files and click Run icon from the toolbar. Android studio installs the app on your AVD and starts it and if everything is fine with your setup and application, it will display following Emulator window −