Android: How to use Localize to translate your Android application

This guide will walk you through the process of using Localize to translate your Android mobile application.

You can also watch this video which shows the process in action.

What you'll learn

  • How to import files, translate files, export files, and load translated files into Android Studio

Prerequisites

  • You have a project set up in Localize
  • You have experience developing Android mobile applications
  • You have Android Studio installed
  • Your Android mobile application uses a strings.xml file for all app copy

Preparing your app for localization

Please review the Android localization documentation for a full understanding of the localization process.

To give an overview of the localization process, Android loads resources stored in the /res directory of your project for use in your mobile application. Within /res/values/strings.xml you should find a file that contains all strings used throughout your application. If you have hard-coded any copy into the template files directly you will need to apply best practices and abstract your strings into a strings.xml file.

When a user’s mobile device is changed to a different language, your mobile application will attempt to load resources for that language by looking in /res/values-[languageCode]. For example, if your mobile device is set to French your application will attempt to load resources from /res/values-fr. In order to translate your application into a particular language you will need to create a new values-xx directory for each of the languages you would like to translate. Within each of these new values-xx folders we will be placing new, translated strings.xml files that contain translations for each of the languages.

Using the Localize Dashboard to translate your app

Import your strings.xml file into Localize

  1. Within your Localize Dashboard go to the Phrases > File Import/Export page
  2. Select Import from the left submenu
  3. Select ANDROID XML as your file type
  4. Your source language will automatically be selected as the only language option
  5. Select an import type of Phrases
  6. Upload and submit your strings.xml file

Translate your imported phrases

Using the Localize dashboard, you may translate your source language phrases into as many languages as you need. If you are unfamiliar with the translation workflow, please see our Basic Translation Workflow with Localize video.

Export your translations into new strings.xml files

  1. Within your Localize Dashboard go to the Phrases > File Import/Export page
  2. Select Export from the left submenu
  3. Select ANDROID XML as your file type
  4. Select your desired phrase filtering options
  5. Select what language you want exported
  6. Select an export type of Phrases
  7. Click Export and your browser will download a copy of your new strings.xml file
  8. Repeat for each language you need in your application
  9. Place a copy of each language file into the corresponding /res/values-[languageCode] directory and rename the file to strings.xml or simply update existing files with content from the new ones.

Test your translated mobile application

Now that your files are properly formatted and loaded into your mobile application, change the language of your emulator or live device to one of your newly installed languages and load up your application. You should see all content properly translated.

Add Localize to your build process

Localize REST API

You can integrate Localize into your build process by writing scripts that make RESTful HTTP requests using the Localize REST API for the import and export of localization files, as well as much more. Our route documentation provides examples of HTTP requests in cURL, Node, Ruby, JavaScript, and Python.

npm module

You may also use our npm module, @localize/node, a Node-based wrapper for Localize’s REST API.

Localize CLI

You can also use the Localize CLI which uses a simple push/pull paradigm to push content into Localize and then pull out the translations.
Read about the CLI