Localization testing for Android

You can unpack the file with apktool, which you’ll likely have to download and install.

If you have a package, foo.apk, then when you unpack it, there will be a directory foo. Inside foo/res/values, you’ll find strings.xml, which will look something like this:

version_string-signed/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="common_android_wear_update_title">Update Android Wear</string>

The string name, common_android_wear_update_title, will be present in all the various strings.## directories, where “##” represents the two letter abbreviations for each language. Depending upon your language, you’ll just need to access the right language file.

It was relatively simple to find code on the net to parse this file: http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash

There are a few gotchas – Android strings files can have multiple entries for the same string based on whether it’s single or multiple, or in case of some languages, zero, so you’ll need to handle that. Also, when your app is compiled, it has some heuristic for when it escapes certain characters, so I had to write code to fix that. There are also html characters you’ll have to handle.

Good luck

1 Like