Thursday, August 26, 2010

Battle Drill: Using Google Translate to Localize Your Apps

Localization allows you to give your app locale-specific settings, such as different languages based on the country where the app is being run.  This is a good idea as it expands the market that can find your app useful.

Task: Localize your app into other languages using Google Translate
Condition:  Given access to Google Translate, a properly-formatted string resource file
Standard:  Your app is available in multiple languages

Procedure:
1. It's important that you keep all strings used in your app in the "/res/values/strings.xml" file.  This makes it easy to localize the apps easy to change the text strings used in your application.  It's easier to hard code some strings in the Java code; don't do it!
And example will look like this:

    <string name="menu_caption">Show Photo Caption</string>
    <string name="menu_mapit">Show on Map</string>
    <string name="menu_wallpaper">Set as Wallpaper</string>

2. Visit http://translate.google.com
3. Click "upload a document"
4. Upload the strings.xml file.  Google Translate understand the formatting of the xml.
5. In Eclipse, create a new '/res/values-xx' folder where 'xx' follows an Android-supported ISO 639-2 language code.
6.  Copy your new translated file (still named strings.xml) to the new 'values' folder.

No comments:

Post a Comment