RSS Feed

Help Your Users Localize your Android App

Posted on Friday, February 15, 2013 in Coding, User

In order to widen the reach of your app, it is necessary to localize it.This increases the desirability of the app with non-native speakers of your language.

Android comes with a resource framework which eases localization of strings in your application. Basically you provide a string resource file for each language with the strings represented by keys. Then in your code, you simply load the string by its key and Android takes care of using the correct string, based on the user’s device locale settings.

When you support only a few locales, it is ok to email the strings file back and forth for translation. However, as the number of supported locales grows, the emailing becomes more of a burden. Here I present some things I’ve learned through managing the 8+ different translations in Gnucash for Android.

Firstly, not all strings.xml files are created equal. Normally in your app, there are not only user interface strings, but also strings for many other non-user facing things like preference keys. These only need to be in the default res/values/strings.xml file since they are not meant to be translated. Android will still find the default strings irrespective of the user locale.

Doing this will also ease the work for your translators since they can simply translate everything in their strings.xml file without having to decide each time if it is a user-interface string or not.

Secondly, if your translators are developers themselves, then it is usually easy for them to send pull requests with translations. However, most of the time, the translators are just normal users of your app who are willing to help.

Asking them to clone/edit/push is a bit too much to ask. If your code is on GitHub, then you can easily have them issue pull requests without having to learn Git. You can do so as follows:

  1. Create the folder for the resource file and copy the strings.xml to the folder e.g. res/values-de/strings.xml for German (de) translations.
  2. Ask your translators to create a GitHub account and log in.
  3. Point your translators to the file which needs to be translated. Each language will have a slightly different link based on the locale code. For example, the German locale: https://github.com/codinguser/gnucash-android/blob/develop/app/res/values-de/strings.xml
  4. If they are logged in, they should be able to see an “Edit” button at the top of the file. They can click this and then directly translate the strings in the browser. edit_strings
  5. When done, they can enter a description of their changes and click “Propose File Change” and the UI for creating a pull request comes up.

propose_change

Then they click on “Send pull request” and you get the changes as a pull request which you can merge easily.

send_pull_request

Your translators have basically accomplished cloning your project, creating a branch, editing and committing their changes, push their changes back upstream and issue a pull request. All without having to learn Git or opening a terminal. Usually there should be no conflicts in the merge since string translation usually comes after feature freeze.

There are some who decry the fact that GitHub basically wraps Git in such a way that it is unidentifiable. But I think there is an argument to be made for those who want to contribute to projects without having to learn technical nitty-gritty details (such as navigating the maze that is Git documentation).

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • Digg
  • del.icio.us
  • Facebook

Bring on the comments

  1. Shaun McCance says:

    How do you manage additions or modificatios to the source strings.xml file? I’m a bit surprised to see a translation workflow that doesn’t use PO or XLIFF files.

    • Ngewi Fet says:

      Well, AFAIK, you have to manually create the strings in the strings.xml file and copy them to the corresponding localization files. Some IDEs do assist you by automatically copying any newly created strings to all the localization files when doing refactoring.

  2. ReinoutS says:

    Two decades of experience with Free Software localization and internationalization tools, and then seeing this makes me want to cry.

  3. Set says:

    Here’s what I did: I imported my strings file to https://poeditor.com/ and took back the translations once they were finished. For all the translators that wanted to work for the project, I just added their email and they were in. You should try it, it works really nice.

Leave a Reply