You are here:    Home  > Blog  

Creating Multilingual Apps in Android

Android

Android apps run in many devices in different regions of the world. To cover the maximum number of users across the world for your android app, Multilingual can play a vital role. Multilingual feature is also known as the localization process of your app.

Before proceeding further, make sure that you have some basic knowledge of creating android apps, handling resources, creating layout XML files etc.

1. Basic Localization Process

Android loads its resources, text and layouts from /res directory in your project folder. The default structure of the /res directory in project folder is like this:

 

1. Basic Localization Process

In order to support localization in our app, we need to add some extra folders for resources, strings for that locale. Android OS itself detects the current locale of the device and picks the most relevant resources from the appropriate folder in res directory.

2. Localizing Strings

To add support for multiple locales, we have to add additional values folders in the /res directory of our project. The naming convention that will be followed to create the additional directory is: values followed by a hyphen and ISO code of the language.

For example: values-fr/ is the directory containing the simple resources for the language with ISO code “fr”.

Now add the string.xml containing the language specific text to the appropriate folder.

In this example we are focusing on French(values-fr) and Japanese(values-ja).

 

Localizing Strings

3. Localizing Images

Similar to values directory, we can create separate directory for drawables that includes the images for their respective locales. Android will automatically detects the current locale setting of the device and load the appropriate images in the app.

  • res/drawable-hdpi: Contains default images for high density.
  • res/drawable-fr-hdpi: Contains images optimized for Japanese.
  • res/ drawable-ja-hdpi: Contains images optimized for French.

Similarly, you can create directories for other drawables too.

 

Localizing Images

4. Testing Localized Application

Once you have localized all the resources in their project, the application is ready for testing.

To test the application, we can set different locales via

Settings -> Language & input or Language & keyboard -> Select Language

and run the application.

5. Localization Checklist

Now as we have understand how to develop multilingual apps in android, let’s look over some checklist that must be kept in mind while developing localized apps:

  1. Never hard code strings in the project, instead use string.xml file.
  2. Never hard code drawables and layouts, instead use drawable and layout directories.
  3. Make sure to include all default directories under /res and all default resources as when Android can’t find any specific locale then it picks the resources from the default directories of resources.
  4. Place your localized resources(images & strings) in the appropriate directories under /res/

Reference links:

  1. http://developer.android.com/guide/topics/resources/localization.html
  2. http://developer.android.com/training/basics/supporting-devices/languages.html

By:

About Vipin Jain

(CEO / Founder of Konstant Infosolutions Pvt. Ltd.) Mobile App Provider (A Division of Konstant Infosolutions Pvt. Ltd.) has an exceptional team of highly experienced & dedicated mobile application and mobile website developers, business analysts and service personnels, effectively translating your business goals into a technical specification and online strategy. Read More