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.
- 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.xmlto Soluling Cloud directly; layouts and images need Soluling Desktop
On this page
- Tutorial: localize an Android application step by step
- How Android localization works
- Comments and length limits
- Language IDs
- Right-to-left languages
- Test in another language
- Translate in Soluling Cloud
- Do and don't
- Typical localizability problems
- Troubleshooting
- Samples
- FAQ
Localize an Android application, step by step
Six steps take the application from hard-coded English to one multilingual application.
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:
-
Move the strings to
res\values\strings.xml. Read them withgetString, and useandroid:text="@string/calculate"in layouts. Keep English in this default file: Android falls back to it. -
Use numbered placeholders. With
%1$sand%2$s, a translator can move the values. Validation checks that the translation keeps every placeholder. -
Use plurals for counts. Add a
<plurals>resource, and read it withgetQuantityString. 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>
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.xmlis, select Android resource file: it is also valid XML, but only this parser understands string arrays, plurals, and thetranslatableattribute. - With the project file, select the resource types on the Resources sheet.
- Select the original language and the target languages, and complete the wizard.
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.
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
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
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.
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.
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.
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, selectres\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 asres\values-fi\strings.xml. When the application changes, upload the newstrings.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
valuesfolder. - Use
<plurals>andgetQuantityStringfor 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
ifstatements; other languages have other rules. - Add
strings.xmlas a generic XML file; you lose plurals and string arrays. - Rename a resource after translation starts; the name identifies its translation.
- Use
leftandrightin 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.ntpandAndroid.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
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.strings.xml to Soluling Cloud, translate in Translate, and download the localized files. See Translate in Soluling Cloud.Related
- Android localization - the full Desktop documentation
- Resource options - what is written, and language IDs
- Patterns - plurals, genders, and selects
- Supported formats - everything else Soluling localizes