Creating Multilingual Apps in 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:
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).
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.
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:
- Never hard code strings in the project, instead use string.xml file.
- Never hard code drawables and layouts, instead use drawable and layout directories.
- 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.
- Place your localized resources(images & strings) in the appropriate directories under /res/
Reference links:
- http://developer.android.com/guide/topics/resources/localization.html
- http://developer.android.com/training/basics/supporting-devices/languages.html
By: Vipin Jain
About Vipin Jain
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 View all posts by Vipin JainRecent Posts
- Airbnb Alternatives: 7 Just as Good Vacation Rental Apps
- React Native vs Xamarin vs Ionic: Best Hybrid App Development Frameworks for 2019
- Best Programming Language for Mobile App Development
- Want You Ride-Sharing App to Succeed? Consider These 4 Strategies from Juno
- How Do Apps Make Money? The Best Strategies and Use Cases
Archives
- May 2022
- June 2019
- May 2019
- April 2019
- March 2019
- February 2019
- December 2018
- January 2018
- December 2017
- October 2017
- September 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2015
- November 2014
- October 2014
- December 2013
- November 2013
- October 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- January 2013
- December 2012
- November 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- August 2011
- May 2011