Lantern’s CLI is on npm as lantern-l10n. It has no dependencies and needs Node 18 or newer, so npx lantern-l10n runs it without installing anything: pull writes locale files, and push sends keys and values back. You can also call the read and write endpoints directly in a few lines.
Pull#
LANTERN_TOKEN=lk_… npx lantern-l10n pull \
--url https://lantern.abyss-inn.ch --project my-project --out localesWrites one locales/<locale>.json per language. Add --locale to pull one language, or --nested for nested JSON. The token comes from LANTERN_TOKEN.
LANTERN_TOKEN=lk_… npx lantern-l10n pull \
--url https://lantern.abyss-inn.ch --project my-project --format android --out app/src/main/resAdd --format android to write an Android res folder instead: values/strings.xml for the default language and values-fr/strings.xml, values-pt-rBR/strings.xml and so on for the others. Point --out at app/src/main/res.
Push#
# Register keys (a JSON array of dotted paths, or [{ "key", "namespace", "description" }])
LANTERN_TOKEN=lk_… npx lantern-l10n push \
--url https://lantern.abyss-inn.ch --project my-project --keys keys.json# Push one locale from a flat or nested JSON file (creating any missing keys)
LANTERN_TOKEN=lk_… npx lantern-l10n push \
--url https://lantern.abyss-inn.ch --project my-project \
--locale fr --in fr.json --create-keysThe keys file is a JSON array of dotted paths, or of objects with key, namespace and description. A locale file can be flat or nested; --create-keys creates any key it doesn’t find. Pushing needs a token with write scopes.
Plurals#
Lantern stores a plural as one key holding an ICU message, so translators see one row and can fill in every form their language needs (few and many in Polish, for example). If your app uses i18next, which keeps one key per form, add --plurals i18next to both commands:
# fr.json uses i18next plural keys:
# { "payIn_one": "{{count}} paiement", "payIn_other": "{{count}} paiements" }
# Lantern stores them as one key:
# payIn = "{count, plural, one {# paiement} other {# paiements}}"
LANTERN_TOKEN=lk_… npx lantern-l10n push --url https://lantern.abyss-inn.ch --project my-project \
--locale fr --in fr.json --create-keys --plurals i18next# Splits payIn back into payIn_one / payIn_other (plus few / many where a language has them)
LANTERN_TOKEN=lk_… npx lantern-l10n pull --url https://lantern.abyss-inn.ch --project my-project \
--out locales --plurals i18nextpush folds payIn_one, payIn_other and their siblings into one payIn key, and pull splits it back. A group folds only when it has an _other form plus at least one more, so an ordinary key that happens to end in _other is left alone. Without the flag nothing changes. The same option is plurals=i18next on the read and write APIs, a plurals argument on the MCP tools, and a toggle on Import and Export.
In GitHub Actions#
Add LANTERN_TOKEN as a repository secret, then pull before you build:
- name: Pull translations from Lantern
env:
LANTERN_TOKEN: ${{ secrets.LANTERN_TOKEN }}
run: |
npx lantern-l10n pull \
--url https://lantern.abyss-inn.ch --project my-project --out localesOr use the pull sample for your language. The build then bundles the fresh files.