Localizing an Android app with strings.xml
Android reads translated text from res/values-<language>/strings.xml. The format is simple, but the resource compiler is strict, and one unescaped apostrophe in a translation stops the build.
Where each language goes
The default language lives in res/values/strings.xml. Every other language gets its own folder, such as values-de or values-pt-rBR. Android picks the closest match for the device locale and falls back to the default file for any key a language is missing.
The escapes that break builds
Apostrophes and double quotes must be escaped with a backslash. A value that starts with @ or ? is read as a resource reference unless it is escaped. Repeated spaces are collapsed unless the value is wrapped in quotes. Translators rarely know any of this.
LocalizeMe applies these escapes on export, so translators type plain text and the file still compiles. Inline styling tags like <b> and <i> stay as markup. A string whose placeholders aapt2 would reject gets formatted="false".
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="welcome">Bienvenue, c\'est parti !</string>
<plurals name="items_in_cart">
<item quantity="one">%d article</item>
<item quantity="many">%d d\'articles</item>
<item quantity="other">%d articles</item>
</plurals>
</resources>Plurals
Languages need different plural forms. English has one and other, French adds many, Polish and Russian need few as well. In LocalizeMe a plural is one key per CLDR form, such as items_in_cart_one and items_in_cart_other, and the Android export folds them into a single <plurals> element.
If a language is missing its other form, the forms it does have are written as plain strings instead. Android would otherwise pick the incomplete <plurals> and crash on any quantity that needs other.
Pulling the files in your build
The CLI writes each language straight into its values folder. The {android_code} placeholder turns a code like pt-BR into the pt-rBR folder name Android expects.
localizeme init --project 42 --format android-xml --platform android \
--path 'app/src/main/res/values-{android_code}/strings.xml' \
--source-path app/src/main/res/values/strings.xml
localizeme pullQuestions
Why does an apostrophe break my Android build?
The Android resource compiler treats an unescaped apostrophe as an error. It has to be written as \' in strings.xml. LocalizeMe adds that escape on export.
Can I import my existing strings.xml?
Yes, including <plurals> and CDATA sections. Each plural form becomes its own key, and the export folds them back into <plurals>.
Can I update Android strings without a release?
Yes, with the LocalizeMe Android SDK, which fetches published strings over the air. It needs the Mobile plan.
Other guides
Unlimited strings, one flat price
LocalizeMe never counts keys, strings or languages. Try Pro free for 14 days, no card needed.