Tutorial details

Android beginner tutorial: Part 86 - Localization | App Code for Sale | Preview

Android beginner tutorial: Part 86 - Localization | Android Tutorial

Application localization

Overview PAGE TOP

In this part we will talk about application localization.

After deployment, your application may be used on Android devices in many regions. To get the most users, you should think about making your application suitable for people speaking different languages - in other words, you should localize it.

Localization is actually fairly easy to implement. Up until now, when we set labels to buttons and text values to textviews and other components, we stored those values in strings.xml file (except some individual cases where we simply hard-coded the text in the xml files for testing purposes). Localization system lets us create multiple string, audio, visual, etc. files for different regions.

By using the res/values/strings.xml file, you're setting the default values for all regions. When told to look for a resource, the Android system picks the one that suits the region of the user. If no such item exists, the default value is picked. That's why if you're using resources in your application, you should always include all of the used values that would be used by default.

The default values stored in res/values/ directory should be using the most common language you expect your application users to speak. Normally, it's English.

To set resources for other regions, use the values- pattern to create new directories and store your resources there. The can be replaced by one or a group of qualifiers (for example, we know we can store images for different pixel density using qualifiers such as mdpi, hdpi, etc.).

As the Android official docs state: the language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r").

Examples of such language codes are "en", "fr", "ca", as well as "en-rUS", "fr-rFR" and "fr-rCA".

This means that we can store values in directories like res/values/strings.xml, res/values-fr/strings.xml, res/values-ja/strings.xml, etc.

And that is pretty much it. Using this information you'll be able to make a flexible Android application which adapts to the user's region.

Thanks for reading!

Reference PAGE TOP

http://kirill-poletaev.blogspot.it/2013/02/android-beginner-tutorial-part-86.html

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.