Android LogoLocalizing Your Android App

You’ve built your app and released it in English only. It’s now time to localize the app and make it available in a number of different languages around the world.

There are essentially 2 areas that you need to translate in order to successfully market your app in the non-English speaking countries of the world.

Marketing Content
  • Play Store Description
  • Keywords
  • Supporting Website
The App
  • User Interface
  • Help

The following sections describe how to prepare your app for translation. They will describe how to set up your Android project so that the entire user interface, including error messages, can be translated into multiple languages.

At the end of the exercise, you will have learned how to prepare your app so that it can be translated into any language.

 

1. Externalizing strings

Hard-coded strings such as error messages and UI elements must be externalized from your source files in order to translate your app. The Android SDK support getText() which works with a file called strings.xml to facilitate the externalization and localization of these strings.
  • Open your Android project.
  • If you do not have a file called strings.xml, you need to create one.
  • Put this file in your values directory
A screenshot showing an example of an Android project structure.
  • The format of strings.xml looks as follows:
An example of the Android native file format strings.xml.
  • The resources section contains a list of strings
  • Each string has a unique identifier
  • These identifiers are used to load the required strings in code using getText()
An example showing the getText() function.
  • The call to getText() above will load the string “Stopped” for the key “message_stopped”
  • All user visible strings in your UI should be “externalized” from the code using calls to getText(), and creating the appropriate entries in strings.xml
  • Once your code is prepared and all of the UI content is externalized into strings.xml, you are ready to start the process of localizing your app
Here are some images of the running app:
An Android app running.
An Android app running.
An Android app running.
As you can see, all of the English text is nicely displayed and everything fits in the menus provided.


2. Setting up Locales

Localizations for various languages are built into your apk file directly. There is no need to ship different language versions of your app. The Android SDK provides full international support for different locales.
To add a new locale to your app:
  • Create a new directory in your res folder
  • If you want to localized your app into French, name this directory values-fr
  • The French version of the file strings.xml will be placed in this directory once it is translated


3. Pseudo-localization Testing

A great way to test the localizability of your app prior to actually getting real translations is to use pseudo-localization. Pseudo-localization is a process that “touches” all of the characters in a localizable string. There are many different methods that can be employed to achieve this. At Tethras, we provide a pseudo-localization scheme which accents all of the vowels and consonants, and lengthens the text by approximately 30%.
That is worth repeating.

Á grèát wᥠtô tèst thè lôçálïzábïlït¥ ôƒ ¥ôúr ápp prïôr tô áçtúáll¥ gèttïñg rèál tráñslátïôñs ïs tô úsè psèúdô-lôçálïzátïôñ. ôñè twô thrèè ƒôúr ƒïvè sïx sèvèñ èïght Psèúdô-lôçálïzátïôñ ïs á prôçèss thát “tôúçhès” áll ôƒ thè çháráçtèrs ïñ á lôçálïzáblè strïñg. ôñè twô thrèè ƒôúr ƒïvè sïx sèvèñ Thèrè árè máñ¥ dèrèñt mèthôds thát çáñ bè èmplô¥èd tô áçhïèvè thïs. ôñè twô thrèè ƒôúr ƒïvè Át Tèthrás, wè prôvïdè á psèúdô-lôçálïzátïôñ sçhèmè whïçh áççèñts áll ôƒ thè vôwèls áñd çôñsôñáñts, áñd lèñgthèñs thè tèxt b¥ ápprôxïmátèl¥ 30%. ôñè twô thrèè ƒôúr ƒïvè sïx sèvèñ èïght ñïñè

You get the idea.

Now to put this into action.

  • The file below is the pseudo-localized version of strings.xml
  • This pseudo-localized version of strings.xml has been placed in the values-fr directory
  • If we now run the app under the French locale in the emulator, we can review the pseudo-localized “French” version of the app and test for localizability

4. Switching Locales

  • Go to System Settings

  • Choose Language & input

  •  Select Language
  • Choose Français (France) from the list that appears
  • The UI of the phone will switch over to French
  • You are now ready to run the app and test the localizability using pseudo-localization

  • In the screenshot above, the text all displays correctly. However, if translation into a language causes the text to grow by more than 30%, the second line of the “Press Up To Play” message may intersect with the lunar module.
  •  In this screenshot, everything appears fine. However, the algorithm of increasing the length of each string by 30% might not be good enough to emulate the translation of single words into other language.
  • Let’s increase the length of the pseudo-translations and see what happens.
  • Android has dynamically changed the menu from 2 rows x 3 columns to 3 rows x 2 columns to accommodate the length of the text. Clever.
Pseudo-localization testing allows you to easily look for hard-coded strings in your app, and to view what will happen to your menus and layouts due to text expansion during translation.