CLI
The CLI (cli/) is an ESM Node 22.12+ package built on commander. It works on the JSON files the
extension exports and imports, which makes it useful for translating without running the server, for
checking a translation file into a repository, and for reviewing translations in a diff.
cd clinpm installnpx any-i18n --helptranslate
Section titled “translate”npx any-i18n translate --input _keys.json --language de [--output de.json]| Flag | Required | Meaning |
|---|---|---|
--input <file> |
yes | Path to a _keys.json export. |
--language <lang> |
yes | Target language code, e.g. de, fr, es. |
--output <file> |
no | Output path; defaults to <language>.json in the working directory. |
The input must contain both _meta and keys, and keys must not be empty — otherwise the command
exits with status 1 and a message. All keys are sent in a single prompt asking for the same keys with
translated values, preserving HTML tags and placeholders.
The prompt is handed to the local claude command (claude -p "<prompt>") with a 120-second timeout
and a 10 MB output buffer. If that command is missing or fails, the CLI says so and exits 1. The
first { ... } block in the response is parsed as JSON, so a fenced answer is still accepted.
Output shape:
{ "_meta": { "domain": "example.com", "language": "de", "translatedAt": "2026-01-15T11:00:00.000Z", "sourceVersion": "1.0.0" }, "translations": { "welcome_to_our_1a2b3c4d": "Willkommen auf unserer Website" }}domain is copied from the key file’s _meta.domain (unknown if absent) and sourceVersion from
its _meta.version or _meta.exportedAt. This is exactly the format the extension’s Import
button expects.
validate
Section titled “validate”npx any-i18n validate --input de.json [--keys _keys.json]Checks the translation file and exits non-zero if anything is wrong:
_metamust exist and containdomain,language, andtranslatedAttranslationsmust exist- empty or whitespace-only values are reported and treated as a failure
- with
--keys, every key from the source file must be present (missing keys fail the run) and keys not present in the source are reported as extras (warning only)
The number of translations found is printed, then either Validation passed. or
Validation failed.. The non-zero exit status makes it usable as a pre-commit or CI check.
bundle
Section titled “bundle”npx any-i18n bundle --input ./translations --output ../extension/translationsCopies every *.json file from the input directory into the output directory (created if needed),
skipping files that are not valid JSON with a message, and writes an index:
{ "generatedAt": "2026-01-15T11:05:00.000Z", "translations": [ { "file": "de.json", "language": "de", "domain": "example.com" } ]}Language and domain come from each file’s _meta, falling back to the file name and unknown.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 |
Success. |
1 |
Unreadable or malformed input, empty key set, provider command failure, unparseable response, or failed validation. |