Managing and Testing Translations in Android applications.

Bego Ros
3 min readJul 5, 2020

--

How to work effectively with apps that handle many locales.

Most products that we work on nowadays support many locales. This can be a challenge both from the developer and the test engineer’s perspectives. When we test apps in the languages that they support, we mostly focus on:

  • Verifying that all strings are displayed on the selected language and that any special characters render correctly— no truncated, overlapping or cut off text. Pay attention to non-latin alphabets such us Russian, Arabic, Hebrew, Chinese etc.
  • Verifying that strings don’t overlap and read correctly on buttons, entry forms, CTA, toolbar, drawer navigation etc.
  • Checking layout for right-to-left languages is mirrored correctly.

However, this process is extremely time consuming as it requires a lot of manual testing. Also, by the time these tickets get into testing, the whole development has been completed so this will require refactoring and re-testing. So, is there a better to do this?

The answer is Pseudo-Locales.

Implementing pseudo-locales into our modules.

A pseudo-locale is a locale that is designed to simulate characteristics of languages that cause UI, layout, and other translation-related problems when an app is translated. Pseudo-locales are created by instant and automatic translations that are readable in English for all localizable messages. Unpseudo-localized text points to untranslatable messages in your source code. Pseudo-locales save time and money because you can make adjustments to the UI text and its layout before you commit your messages to the source repository to be sent for translation later.

The Android platform provides the following two pseudo-locales to represent Left-to-right (LTR) and right-to-left (RTL) languages:

  • English (XA): Adds Latin accents to the base English UI text, expands the original text by adding non-accented text, and brackets each message unit to expose potential issues from expanded text. Potential issues can be layout breakage and badly formed message syntax as shown by one sentence split into multiple parts displaying as multiple bracketed messages.
  • AR (XB): Sets the text direction of the original left-to-right messages to the right-to-left direction, which reverses the order of the characters in the original message.

In Android Studio enable pseudo-locales for a specific app by adding the following configuration to your build.gradle file, as follows:

android {
...
buildTypes {
debug {
pseudoLocalesEnabled true
}
}

Benefits of implementing pseudo-locales in app:

  1. Hardcoded strings are displayed as unaccented text so they are easier to spot. This makes it easier to find out missing translations etc.
  2. UI layout issues causes by text expansion, for example, the UI breaking due to the length of the text, text overlapping etc.
  3. Right-to-Left issues: elements not being mirrored correctly(text not being displayed in the opposite way, buttons not moving accordingly etc.)
  4. Anticipate any layout issues before you have the translated strings added and before these are spotted by test.

For more information on pseudo-locales check out the Android documentation.

--

--