Android

Last updated: December 01, 2022Author: Jakub Pomykała

Hey there, this article may be outdated. If you are an Android developer, and you have some spare time, it's a great opportunity to contribute to our documentation and get some benefits! Learn about our contributor program.

Learn how to localize your Android app with SimpleLocalize using translations in strings.xml files. This guide will help you to get started with SimpleLocalize and translation editor in a few minutes.

Table of contents

Before you start

Before you start, you need to have a SimpleLocalize account. If you don't have one yet, you can sign up for free. Create a new project and add get your API Key.

Install SimpleLocalize CLI

SimpleLocalize CLI is a command line tool that helps you to integrate localization into your development workflow. It can be used to upload and download translations from SimpleLocalize.

# macOS / Linux / Windows (WSL) curl -s https://get.simplelocalize.io/2.7/install | bash # Windows (PowerShell) . { iwr -useb https://get.simplelocalize.io/2.7/install-windows } | iex;
# macOS / Linux / Windows (WSL)
curl -s https://get.simplelocalize.io/2.7/install | bash

# Windows (PowerShell)
. { iwr -useb https://get.simplelocalize.io/2.7/install-windows } | iex;

Upload strings.xml files

In this step, you will upload your strings.xml files to SimpleLocalize. Thanks to the command-line tool, you can upload multiple files at once from any directory.

Copy
$ simplelocalize upload \ --apiKey YOUR_API_KEY \ --uploadFormat android-strings \ --uploadPath ./resources/values-{lang}/strings.xml
$ simplelocalize upload \
        --apiKey YOUR_API_KEY \
        --uploadFormat android-strings \
        --uploadPath ./resources/values-{lang}/strings.xml

You may also want to upload only one file for a specific language. To do that, you can use the --languageKey option with the language key from the Languages tab.

$ simplelocalize upload \
        --apiKey YOUR_API_KEY \
        --languageKey en \
        --uploadFormat android-strings \
        --uploadPath ./values/strings.xml

Extract translation keys (optional)

If you don't have translation keys in your strings.xml files, you can use the extract command to generate them automatically. CLI can find translation key usages in .java and .kt files. Translation keys will be automatically uploaded to the translation editor.

$ simplelocalize extract \ --apiKey YOUR_API_KEY \ --projectType google/android \ --searchDir ./src
$ simplelocalize extract \
        --apiKey YOUR_API_KEY \
        --projectType google/android \
        --searchDir ./src

Translate your Android app

Now you can translate your Android application strings using the translation editor and save changes.

Manage your translation strings in Translation Editor

If you want to translate your app in multiple languages fast, you can add new languages in the Languages tab, and use auto-translation feature to speed up the process.

How to start auto-translation for many languages at once

Download translated strings.xml files

Once you finish the translation, you can download the translated strings.xml files using the download command. CLI will download the files to the resources/values-{lang}/strings.xml files, where {lang} is the language code set in Languages tab.

$ simplelocalize download \ --apiKey YOUR_API_KEY \ --downloadFormat android-strings \ --downloadPath ./resources/values-{lang}/strings.xml
$ simplelocalize download \
        --apiKey YOUR_API_KEY \
        --downloadFormat android-strings \
        --downloadPath ./resources/values-{lang}/strings.xml

You may also want to download only one file for a specific language. To do that, you can use the --languageKey option with the language key from the Languages tab.

$ simplelocalize download \
        --apiKey YOUR_API_KEY \
        --languageKey en \
        --downloadFormat android-strings \
        --downloadPath ./values/strings.xml

Resources

Was this helpful?