Localization Services for Android Mobile Applications
Consumers are using all channels available to them to interact and engage with your brand whether it be via mobile, website, email, social, brick and mortar-you name it. Marketers know they cannot risk neglecting any one channel or they might miss an opportunity.
“Android has been one of the primary growth engines of the smartphone market since it was launched in 2008,” said Ramon Llamas, research manager, Mobile Phones at IDC. “In every year since then, Android has effectively outpaced the market and taken market share from the competition. In addition, the combination of smartphone vendors, mobile operators, and end-users who have embraced Android has driven shipment volumes higher. Even today, more vendors are introducing their first Android-powered smartphones to market.”
Top Six Smartphone Mobile Operating Systems, Shipments, and Market Share, Q3 2012 (Preliminary) (Units in Millions)
Operating System |
3Q12 Shipment Volumes |
3Q12 Market Share |
3Q11 Shipment Volumes |
3Q11 Market Share |
Year Over Year Change |
Android |
136.0 |
75.0% |
71.0 |
57.5% |
91.5% |
iOS |
26.9 |
14.9% |
17.1 |
13.8% |
57.3% |
BlackBerry |
7.7 |
4.3% |
11.8 |
9.5% |
-34.7% |
Symbian |
4.1 |
2.3% |
18.1 |
14.6% |
-77.3% |
Windows Phone 7/ Windows Mobile |
3.6 |
2.0% |
1.5 |
1.2% |
140.0% |
Linux |
2.8 |
1.5% |
4.1 |
3.3% |
-31.7% |
Others |
0.0 |
0.0% |
0.1 |
0.1% |
-100.0% |
Totals |
181.1 |
100.0% |
123.7 |
100.0% |
46.4% |
Source: https://www.idc.com
Android was designed to run a wider number of varying devices in many different regions globally. This blog describes some best practices to consider when localizing and managing multi-language applications to help engage with your users in different locales on the Android platform.
Understanding Application Resources
Application resource files are data files (e.g. images, audio and video) used by your application. When you create a localized application, you also create one or more resource files that contain resources localized for specific cultures and locales. You can deploy these resources within your application to target one or more cultures. Additionally, Android can select and load resources from different directories, based on the current device configuration and locale.
Globalization in the context of application development provides support for localized user interfaces and data for users in multiple cultures. The term, “globally aware application” refers to an application which was been built to present its data using the locale-sensitive symbols (e.g. currency, decimal symbols, etc.) and formats which may be applicable to the given culture.
Software development practices encourage approaches which yield high maintainability and re-use. Application resources files (e.g. images, sprites, layouts and static strings) should be externalized from your source code. This helps development teams to easily maintain them independently and consistently (i.e. leverage build automation tools, etc.)
Supporting Multiple Languages with Application Resources
It’s always a good practice to extract UI strings from your application source code and keep them in an external file.
To support multiple languages, you must provide additional resources for each of the target languages. You should place each type of resource in a specific subdirectory of your project’s resources (i.e. “res/”) directory. Once you’ve decided on the languages (e.g. Three languages – English, Spanish and French) you will support, create the resource subdirectories and string/image resource files. For example:
MySuperSecretAndroidProject/
res/drawable-hdpi/
background.png
drawable-es-hdpi/
background.png
drawable-fr-hdpi/
background.png
values/
strings.xml
values-es/
strings.xml
values-fr/
strings.xml
Strings
Language string.xml | Destination within project | |
English | res/values/string.xml | <?xml version=”1.0″ encoding=”utf-8″?> <resources> <string name=”title”>My Super-Secret Application</string> </resources> |
Spanish | res/values-es/string.xml | <?xml version=”1.0″ encoding=”utf-8″?> <resources> <string name=”title”> Mi Aplicación Secret</string> </resources> |
French | res/values-fr/string.xml | <?xml version=”1.0″ encoding=”utf-8″?> <resources> <string name=”title”> Mon secret application</string> </resources> |
Images
Language background.png | Destination within project |
English (default locale) | res/drawable-hdpi/background.png |
Spanish | res/drawable-es-hdpi/background.png |
French | res/drawable-fr-hdpi/background.png |
At runtime, the Android system uses the appropriate set of string resources based on the locale currently set for the user’s device.
Using the Localized Resources
Once you externalize your application resources, you can access them using resource IDs that are generated in your project’s R class.
Therefore within your source code, you can reference a string resource with the syntax R.string.<string_name>.
For example:
// Get a string resource from your app’s Resources
String title = getResources().getString(R.string.title);