Android Pseudolocalization Update

It's been many years since I last wrote about Android pseudolocalization. There's even some official documentation now!

I'm back because of two small speedbumps I've since run into when using pseudolocalization.

Why Isn't It Working?!

You go into your build script, add pseudoLocalesEnabled true, change your device's locale and... nothing. The rest of the system now looks wacky, but your app remains the same. Huh... must be a buggy feature, right?

Wrong! I'd put good money on your build files also including resConfigs:

android {
  defaultConfig {
    ...
    resConfigs "en", "fr"
  }
}

Google recommends using resConfigs to limit which locales you put into your APK. But pseudolocales are, well, locales. Thus, resConfigs can toss out the generated pseudolocales.

The solution is simple; just include the pseudolocales in your resConfigs list:

android {
  defaultConfig {
    ...
    resConfigs "en", "fr", "en_XA", "ar_XB"
  }
}

Too Much of a Weird Thing

When I first wrote about pseudolocalization I recommended using xliff:g for formatted strings so that the templates would remain untouched by the pseudolocalizer. But what if the entire string should remain constant?

For example, Facebook login asks you to add two strings to your strings.xml:

<string name="facebook_app_id">[APP_ID]</string>
<string name="fb_login_protocol_scheme">fb[APP_ID]</string>

The pseudolocalizer will take that string and happily screw around with it, completely destroying the functionality of your app.

The solution is to mark the entire string as untranslatable so the pseudolocalizer won't touch it:

<string name="facebook_app_id" translatable="false">[APP_ID]</string>
<string name="fb_login_protocol_scheme" translatable="false">fb[APP_ID]</string>