Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Finding and Translating Strings

Published? true
FormatLanguage: WikiFormat

Problem:

You need to find all the strings in your application, internationalize them, and begin the process of translating them.

Solution:

There are several good tools as well as collaborative and commercial services that translate text files.

Discussion:

Suppose you have a mix of old and new Java code in your app; the new code was written specifically for Android, whilst the older may have been used in some other Java environment. You need to find every String literal, isolated it into a Strings.xml file, and translate it into any necessary languages.

The Android Localizer from Artful Bits Inc. is a free and open-source tool that can be used to handle both steps of this process. Motodev Studio is a freely available (with signup) commercial tool that includes this functionality (as well as quite a bit more). Both tools will feed your strings through Google Translate to get a starting version in multiple languages.

Imagine a slightly different scenario: suppose your organization has a "native" (Objective C) application from iOS and you are building the "native" Java version for Android. Here, the properties files are in very different formats - on iOS there is a Java-Properties-like file but with the default (probably English) Strings on the left and the translations on the left. No names are used, just the actual strings, so you might find something like the following:

You-not us-are responsible=You-not us-are responsible

You cannot translate this directly into XML, since the 'name' is used as an identifier in the generate R (Resources) class, "-" and ' ' characters are not valid in Java identifiers. Doing it manually you might come up with something like this:

<string name="you_not_us_are_responsible">You-not us-are responsible</string>

User "johnthuss" has a version of a a Java program to perform this translation, handling characters that are not valid identifiers.

Now, at any rate, you are ready to begin translating your master resource file into other languages. While it may be tempting to scrimp on this part of the work, it is generally worthwhile to engage the services of a professional translation service skilled in the particular language(s) you target. Alternately, you may wish to investigate crowd-sourced translation.

When using any third-party translation service, especially for languages with which you or your staff are not personally "first or second childhood language" familiar, you should normally get a second opinion. Embarrassing errors in software shipped with "bad" translations can be very expensive. There is an apocryphal story, widely used as a warning of this point, of Microsoft inadvertently hiring Taiwanese translators to translate the mainland Chinese version of Microsoft Windows. Here is one reference to this incident: "... The discovery, in the summer of 1996, that some Microsoft programs localized in Chinese carried hidden slogans has again strained Microsoft-PRC relations."

The citation given is to the South China Morning Post, October (day unknown), 1996. It appears in Software Localization: Notes on Technology and Culture by Kenneth Keniston, January 17, 1997, Working Paper #26, Program in Science, Technology, and Society, Massachusetts Institute of Technology Cambridge, Massachusetts 02139. Online (PDF) here; viewed 2011-11-04.

A quick web search will find many commercial services that perform translations for you, as well as some that help with the Internationalization part of the work.