Android-Apps mühelos lokalisieren

Get Localization für Android

Overview

Get Localization supports Android strings.xml file format.

This guide is divided into three sections: Internalization, Set up your Get Localization project and Managing resource files. Internalization explains how you externalize your strings to resource files using Android i18n framework. Then you will learn how to set up a Get Localization project for your app. Managing resource files section will explain the steps to update the master and translations files and to create a Continuous Localization process for your app.

Internalization

Software Internationalization is a process to separate content from code so that it can be localized. If you are unfamiliar with the concept, please read our blog post Software Internationalization for Dummies for starters.

Strings.xml file is the 'human readable' version of the localization file. Your app actually won't access this file directly. Instead when you compile your application, the SDK will also compile the strings.xml file to a binary format and generate a piece of Java code that will let you access the the file in the runtime. This Java class is typically named as R (as Resource). The R class contains all resource element names that you have in your strings.xml and other resource files. This allows easy access to these resources just by using the final variable that the R class provides, for example if you wish to set title for a dialog you would call it like this:

dialog.setTitle(R.string.hello_world);
You can find more information in Android developer documentation

Set up your Get Localization Workspace

Next you need a Get Localization Workspace for your app. Sign up and create a new Workspace here. Remember your Workspace name as you will need it later.

Managing resource files

Continuous Localization Process

Continuous localization means that the process is automated. I.e. when you update your app, you can run a simple script that uploads your updated content to Get Localization server for translation and updates the latest translations back to your app. We provide a simple command-line tool that makes this easy for you. Here are the steps how you initialize your project, push the files for translation and pull the translations back to your application.

Install the Get Localization Command Line Tool

sudo pip install gl

Next initialize the project

cd my/project/root/
gl init [projectname]

projectname is the Workspace you created to Get Localization. Your project root is typically the same dir where you have cloned your git/hg repository.

Add your values/strings.xml to the Get Localization repository

gl add res/values/strings.xml

This is something you need to do only once. glcli is now tracking the file automatically.

Push your file(s) to Get Localization server

gl push

Now your file is ready for translation and you can proceed to your Get Localization project. Simply add the languages you wish to translate your app into and click Order translations.

Configuring translation pull

Next you need to map the translation files so that they are placed correctly in your local file system (note that you need some translations already in the system). First check status of your project.

gl status

This returns the status of your translations and also the corresponding language code. Let's assume that you have a French project and the language code is 'fr':

gl map-locale res/values/strings.xml fr res/values-fr/strings.xml

This means that the French translation of the file res/values/strings.xml is saved as res/values-fr/strings.xml. This information is saved in your local repository, you only need to do this once. Repeat this command for all your language projects.

Pull translations from server

gl pull

Summary

After setup, you simply push the translations to server with gl push command, and pull the translations back with gl pull command. Your continuous localization script could look something like this:

update-l10n.sh:

gl pull
gl push
It's recommended to pull the current translations before updating the new master file as processing takes some time.