Formats
Android XML
Translate Android string resources (strings.xml) across res/values folders.
Android apps store their strings as XML resources, with the default language in res/values/strings.xml and one res/values-<code>/ folder per additional language.
Install the format package:
npm install -D @eloqnt/format-android-xml
Then reference it from your configuration:
.eloqnt/config.ts
import {defineConfig} from '@eloqnt/cli';export default defineConfig({messages: {path: {source: './app/src/main/res/values/strings',targets: './app/src/main/res/values-{code}/strings'},locales: ['de', 'de-AT', 'es-419'],sourceLocale: 'en',codes: {'de-AT': 'de-rAT','es-419': 'b+es+419'},format: {codec: '@eloqnt/format-android-xml',extension: '.xml'}}});
Two things are specific to Android's folder layout:
- The source language has no locale marker. Android keeps the default language in the bare
values/folder, sopathsplits into asourcepath and atargetstemplate. - Folder names use Android's own locale syntax, mapped via
codesfor the{code}placeholder whilelocaleskeeps the real tags.
This resolves to:
./app/src/main/res/values/strings.xml(source)./app/src/main/res/values-de/strings.xml(no code mapping)./app/src/main/res/values-de-rAT/strings.xml(mapped)./app/src/main/res/values-b+es+419/strings.xml(mapped)
Plurals
Quantity strings appear as ICU messages in eloqnt, named after the resource:
res/values/strings.xml
<plurals name="notes_count"><item quantity="one">%d note</item><item quantity="other">%d notes</item></plurals>
The resource above reads as {notes_count, plural, one {%d note} other {%d notes}} in lint output and during translation.
Not supported
The following features are not supported:
<string-array>elements: Their items are positional and unnamed, which is why most localization tools can't translate them reliably. To solve this, give each item its own<string>and reference those from the array via@string/….srcPath: Source code analysis is currently limited tonext-intl.