Android

Android Localization

Localize an Android application: keep the strings in strings.xml, translate them in Soluling, and let Soluling write the localized resources that Android Studio builds into your application.

Soluling reads the resource file, or the whole Android Studio project to also localize layouts, images, and other resources. It shows plurals in a pattern editor, checks the placeholders, and writes each language into its own resource folder. Translate in Soluling Desktop or, for string resources, in a browser with Soluling Cloud. The guide follows the Driving sample, a small driving time calculator.

Try Soluling

Resources XML strings.xml Soluling Original (English) Translation (Finnish) Driving Time Driving distance: Speed: Calculate Driving time is %1$s and %2$s one %d hour other %d hours one %d minute other %d minutes Ajoaika Ajomatka: Nopeus: Laske Ajoaika on %1$s ja %2$s one %d tunti other %d tuntia one %d minuutti other %d minuuttia The strings in strings.xml have been translated Localized resources XML strings.xml fi values-fi\strings.xml de values-de\strings.xml ja values-ja\strings.xml A localized strings.xml for each language, built into one application Resources XML strings.xml Soluling Original (English) Translation (Finnish) Driving Time Driving distance: Speed: Calculate Driving time is %1$s and %2$s one %d hour other %d hours one %d minute other %d minutes Ajoaika Ajomatka: Nopeus: Laske Ajoaika on %1$s ja %2$s one %d tunti other %d tuntia one %d minuutti other %d minuuttia The strings in strings.xml have been translated Localized resources XML strings.xml fi values-fi\strings.xml de values-de\strings.xml ja values-ja\strings.xml A localized strings.xml for each language, built into one application
You sign and publish the application as usual. With an Android App Bundle, Google Play installs only the languages that the device uses.
Input
A resource file (res\values\strings.xml) or the Android Studio project (.iml)
Output
Localized resources in language folders (res\values-fi\strings.xml)
Runtime
Android uses the resources of the device's language, with no code
Cloud
Upload strings.xml to Soluling Cloud directly; layouts and images need Soluling Desktop

On this page

Tutorial

Localize an Android application, step by step

Six steps take the application from hard-coded English to one multilingual application.

01

Prepare: move the strings to resources

Strings in the code can't be localized. A typical problem looks like this:

timeView.setText("Driving time is " + hours + " hours and " + minutes + " minutes");

Internationalizing the application takes three changes:

  1. Move the strings to res\values\strings.xml. Read them with getString, and use android:text="@string/calculate" in layouts. Keep English in this default file: Android falls back to it.
  2. Use numbered placeholders. With %1$s and %2$s, a translator can move the values. Validation checks that the translation keeps every placeholder.
  3. Use plurals for counts. Add a <plurals> resource, and read it with getQuantityString. Other languages have other plural forms.
<string name="time">Driving time is %1$s and %2$s</string>

<plurals name="hours">
  <item quantity="one">%d hour</item>
  <item quantity="other">%d hours</item>
</plurals>
Moving a hard-coded string to resources Before, the result is built from English pieces in the code. After, the code reads plural and string resources from strings.xml, which Soluling shows with Finnish translations. Before timeView.setText("Driving time is " + hours + " hours and " + minutes + " minutes"); ✕ Stays English, no plural forms Internationalize After: DrivingActivity.java String hoursStr = res.getQuantityString(R.plurals.hours, hours, hours); String minutesStr = res.getQuantityString(R.plurals.minutes, minutes, minutes); timeView.setText(String.format(res.getString(R.string.time), hoursStr, minutesStr)); strings.xml in Soluling time English Driving time is %1$s and %2$s Finnish Ajoaika on %1$s ja %2$s hours Finnish one: %d tunti, other: %d tuntia ✓ Translated, with the plural forms of each language
02

Add: choose the resource file or the project

Soluling localizes an Android application in two ways:

Resource file Project file
You add app\src\main\res\values\strings.xml The Android Studio project, such as Driving.iml
It localizes Strings, string arrays, plurals, and other values Also layouts, menus, images, and other resources
New resource files You add each file to the project Soluling finds them
Where Soluling Desktop or Soluling Cloud Soluling Desktop

Use the resource file if you only need the strings or want to use Soluling Cloud. Use the project file if you also localize layouts or images. Drag and drop the file on Soluling, and Project Wizard starts.

  • If Soluling asks what kind of file strings.xml is, select Android resource file: it is also valid XML, but only this parser understands string arrays, plurals, and the translatable attribute.
  • With the project file, select the resource types on the Resources sheet.
  • Select the original language and the target languages, and complete the wizard.
Project Wizard strings.xml or Driving.iml goes through Project Wizard's Resources sheet (string, layout, and drawable resources) and the languages (Finnish, German, Japanese). Drop res\values\strings.xml or Driving.iml Resources ☑ String resources ☑ Layout resources ☑ Drawable resources Languages Finnish (fi) German (de) Japanese (ja) The Resources sheet is for the project file; a resource file holds only values.
03

Translate: strings, plurals, and images

Each string is a row in the grid, identified by its resource name, such as calculate. Strings with translatable="false" are left out. Plurals open in the pattern editor, which shows the plural forms that each target language needs, such as one and other in Finnish and only other in Japanese. With the project file, you can also translate the text in layouts and replace images for each language. See Comments and length limits to give translators more information.

  • Machine translation and translation memory. Click Use Machine Translation to translate with Amazon, Claude, DeepL, Google, Microsoft, ModernMT, or MyMemory, and reuse earlier translations from translation memory and terminology.
  • External translators. Send a translation package, an Excel file, or XLIFF to a translator, and import the results back. See teamwork.
  • Translators in a browser. Upload the project to Soluling Cloud and let translators work in Translate.
04

Check: find problems before release

Pseudo translation. Click Translate | Pseudo Translations | Fill, build, and run the application. Pseudo translations are longer and use accented characters, so texts that don't fit and strings still in the code (shown in plain English) stand out. See pseudo translation.

Pseudo-translated build

[Ðŕîvîñĝ Ţîɱé ___] PS [Ðŕîvîñĝ ðîšţåñçé: ____] 220 [Šþééð: __] 88 [Çåļçûļåţé _] Driving time is 2 hours and 30 minutes Still English (hard-coded)
The Driving sample has no hard-coded strings; this figure shows what one would look like. Check also that longer text still fits your layouts.

Validation. Soluling validates translations while you type and in batch (Validation | Validate Translations): missing translations, inconsistent placeholders and patterns, duplicate hotkeys, and more. See validation.

Validation

⚠ Inconsistent format string time (German) The original has %1$s and %2$s; the translation has only %1$s: Fahrzeit: %1$s ⚠ Maximum characters two The translation is longer than the limit in its comment, MaxChars=20.
05

Build: create the localized resources

Choose Home | Build All. Soluling writes the localized resources into your project, in a folder for each language. Then build the application in Android Studio as usual. Soluling creates resource files and not application files, so it doesn't sign anything: you sign the application when you build it.

What a build creates A resource file creates a localized strings.xml in values-fi, values-de, and values-ja. A project file also creates localized layouts and images, such as layout-fi and drawable-fi. Android Studio builds them into one application. Resource file DIR app\src\main\res\ XML values\strings.xml original, English fi values-fi\strings.xml de values-de\strings.xml ja values-ja\strings.xml Project file DIR app\src\main\res\ XML layout\main.xml original, English fi values-fi\strings.xml fi layout-fi\main.xml if it has translations fi drawable-fi\flag.png if you replace the image
06

Update: translate only what changed

When the resources change, click Home | Scan. Soluling keeps the existing translations, adds the new strings, and marks the rows whose original text changed. Rows are matched by the resource name, so keep the names stable. Translate the new rows, build, and rebuild the application. Add the scan and build steps to your build pipeline with SoluMake or, with Soluling Cloud, SoluCLI.

Reference

Resource folders choose the language

Android applications keep resources in the res folder, and a qualifier in the folder name says what they are for. values-fi holds the Finnish values. All the languages are built into one multilingual application, and Android chooses by the device's language. You write no code for it.

Soluling writes only the rows whose translation differs from the original by default, so a string that is missing from values-fi comes from the default values folder. You can change this on the Resource options sheet.

Resource lookup on a device in Finnish (Finland) On a device in fi-FI, there is no values-fi-rFI folder, so Android uses values-fi. app_name and calculate are found there as Ajoaika and Laske. A string that was not translated comes from the default values folder. UI culture: fi-FI values-fi-rFI not in the application values-fi values default, English app_name – ✓ Ajoaika calculate – ✓ Laske new_string – not translated ✓ A new string

Should layouts refer to @string resources or hold the text themselves? Android's documentation recommends resources, and they are needed if several layouts share a text. With the project file, Soluling also translates text in a layout, and the translator can use a shorter translation in a layout that has less space.

Jetpack Compose has no layout files. Keep the strings in strings.xml, read them with stringResource, and use the resource file method.

Comments and length limits

Give translators more information with a comment attribute, or with an XML comment right before the string. Soluling shows it as the row's comment, and it can set a maximum length that validation checks:

<string name="two" comment="Number two MaxChars=20">Two</string>
<string name="three" comment="Number three MaxPixels=100">Three</string>

<!-- Number five MaxChars=20 -->
<string name="five">Five</string>

Language IDs

Some devices use deprecated IDs for a few languages: iw for Hebrew (he), in for Indonesian (id), and ji for Yiddish (yi). If you localize into these, set Soluling to write both IDs on the Resource options sheet, so that the application works on all devices. The default is the current ID. See Android language IDs.

Right-to-left languages

To mirror the user interface in Arabic and Hebrew, add android:supportsRtl="true" to the application element of AndroidManifest.xml. In layouts, use start and end instead of left and right, such as android:layout_marginStart.

Test in another language

Run the application on a device or on the Android Studio emulator, and change the language: open Settings, choose System | Languages, add the language, and move it to the top of the list. Start the application again. On Android 13 and later, you can also change the language of one application in App languages, if the application declares its languages.

Translate in Soluling Cloud

With Soluling Cloud, translators use Translate in a browser. How you start depends on what you localize:

  • String resource files (strings.xml). On the dashboard, add a project, select res\values\strings.xml, and choose Android resource file (.xml) as the source type, not generic XML. Translators work in Translate; click Build localized files, and save each download to the folder of its language, such as res\values-fi\strings.xml. When the application changes, upload the new strings.xml; the existing translations are kept.
  • Layouts, images, and other resources. These need the project file method, and Soluling Cloud can't read an Android project itself. Create the project in Soluling Desktop, and choose Translate | Configure Cloud to upload it. Use Import from Cloud to get the translations back and build the localized files locally. Your application files never leave your machine.

To run the scan, upload, import, and build steps in your build pipeline, use SoluMake. See the Cloud tutorial and workflows.

Do and don't

Do

  • Keep every string the user sees in resources.
  • Keep the original language in the default values folder.
  • Use <plurals> and getQuantityString for counts.
  • Use numbered placeholders, such as %1$s.
  • Set translatable="false" on strings that aren't for translation.
  • Pseudo-translate before the first real translation.

Don't

  • Hard-code strings or build sentences from pieces in the code.
  • Choose plural forms with if statements; other languages have other rules.
  • Add strings.xml as a generic XML file; you lose plurals and string arrays.
  • Rename a resource after translation starts; the name identifies its translation.
  • Use left and right in layouts if you support right-to-left languages.

Typical localizability problems

See also internationalization and pseudo translation.

Problem How it shows Find and fix
Strings in code English text in a pseudo-translated build Move them to strings.xml, and read them with getString.
Sentences built from pieces Word order and grammar are wrong in the translation Use one string with numbered placeholders.
Plural forms in code Grammar is wrong for some counts Use a <plurals> resource.
Fixed sizes Clipped text in the pseudo or German build Use wrap_content and let the layout grow.
Text in images The image stays in English Keep the text in resources, or replace the image per language with the project file method.

Troubleshooting

Symptom Likely cause What to do
The application stays in English The device's language has no folder, or the application wasn't built again Check the folder name, such as values-fi, rebuild, and check the device's language.
Hebrew, Indonesian, or Yiddish doesn't load on some devices The device uses the deprecated ID Write both IDs; see Language IDs.
Plurals appear as plain rows or are missing The file was added as a generic XML file Create the project again with Android resource file.
Layout text or images aren't in the project The project uses a resource file, or the resource type isn't selected Use the project file, and check the type on the Resources sheet.
A new string isn't translated The string wasn't scanned Click Home | Scan, translate, build, and rebuild the application.
The application can't be published It is signed with the debug key Sign it with your release key in Android Studio; Soluling doesn't sign it.

Samples

The samples are in Samples\Android of the Soluling installation and on GitHub:

  • Driving: the driving time calculator of this guide, in Java, with strings, plurals, a layout, and images, and Finnish, German, and Japanese translations. It has a Soluling project for each method: strings.ntp and Android.ntp. Try this first.
  • Simple: a minimal application with a string hard-coded in a layout file.
  • LayoutSample: localizing layout files.
  • Comments: comments and length limits in string resources.
  • Plural: plural messages with getQuantityString.
  • Old\BiDi: right-to-left languages.

See Android localization in the Desktop documentation for all the details.

FAQ

Add strings.xml if you only need the strings or want to use Soluling Cloud. Add the project if you also localize layouts and images, or want Soluling to find new resource files itself.

Yes, for string resources. Upload strings.xml to Soluling Cloud, translate in Translate, and download the localized files. See Translate in Soluling Cloud.

No. One application holds every language, and Android chooses by the device's language. With an Android App Bundle, Google Play installs only the languages that the device uses.

Yes. Soluling reads the resources, not the code, so it makes no difference whether the application is written in Kotlin or Java.

No. Soluling creates resource files. You sign the application when you build it in Android Studio.

Related

All guides