Android XML
strings.xml with plurals and comments intact
Every native Android app ships its strings in strings.xml,
and the format carries more than key and value: <plurals> blocks,
comments for translators, and escaping rules XML enforces. locamorph reads all of
it, maps plural quantities onto CLDR categories, and writes back files Android
Studio accepts without complaint.
Backslashes and characters XML cannot carry are escaped correctly on export, and the round trip test proves the file that comes out reads back as the file that went in.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Title of the checkout screen -->
<string name="checkout_title">Bestellübersicht</string>
<string name="menu_home">Startseite</string>
<plurals name="cart_items">
<item quantity="one">%d Artikel</item>
<item quantity="other">%d Artikel</item>
</plurals>
</resources> In locamorph
How locamorph handles strings.xml
Quantities become CLDR forms
quantity="one" through "other" map onto the same
plural model every other format uses, so a plural authored for Android exports
cleanly to JSON or ARB.
Comments ride along
The comment above a string imports as its note and is written back above the string on export. Context written for translators stays in the file.
Escaping handled, not hoped for
Apostrophes, backslashes and characters XML cannot represent are escaped the way Android expects. No more build breaks from a French apostrophe.
Ecosystem
Where strings.xml lives
strings.xml is mandatory for native Android: the resource system
picks values-de, values-fr and friends by device locale
across billions of devices. If you build with Android Studio, this file is your
single source of user facing text.
Typical flow: the repo keeps one file per locale under res/values-*,
GitHub or GitLab
imports new keys when developers push, and translated files return as a pull
request formatted exactly like the source.
Related
Keep going
Bring your values folder
Import a strings.xml on the free plan and watch plurals, comments and escaping arrive intact. Exports drop straight into res/values.