CLI and agents
Validate in CI
The tolkbot validate command checks your translation files for problems, and exits non-zero when it finds one — so it works as a build gate, not just a report.
Usage
Run validation from your project root:
tolkbot validate
TolkBot reads your tolkbot.json configuration and validates every translation file it finds. No authentication is needed — validation is entirely local, so it runs anywhere, including sandboxes with no network.
| Option | Description |
|---|---|
--json | Emit the report as JSON instead of a table; the default without a terminal |
--no-json | Print the table even without a terminal |
--strict | Treat warnings as errors, failing the build |
Exit codes
| Code | Meaning |
|---|---|
0 | No errors. Warnings may still be present without --strict. |
1 | At least one error — or, under --strict, at least one warning |
Checks performed
Findings come at three levels, and the level decides whether your build fails.
Errors — always fail
| Check | Description |
|---|---|
| File parses | Every locale file is syntactically valid |
| Placeholder integrity | A translation keeps the interpolation tokens its source string has |
| Translations exist | The project has locale files TolkBot can read |
| Base locale | One locale can be identified as the source of truth |
Warnings — fail only under --strict
| Check | Description |
|---|---|
| Missing keys | Keys present in the base locale but absent from a target |
| Empty file | A locale file that contains no keys |
| Empty values | A key whose value is blank where the base has text |
| Plural forms | A plural without every form the target language needs, e.g. Polish few and many |
| Wrong script | A value with no character of its language's script, e.g. Latin text in a Korean file |
| Left as source | A sentence left exactly as the base locale has it |
Info — never fail
| Check | Description |
|---|---|
| Extra keys | Keys in a target locale that the base locale doesn't have |
| Convention | Layout hints for your framework |
While TolkBot is translating, a target locale is supposed to be behind the base — that's the normal state between a key landing in your base file and the translation PR merging. If that failed the build, every repo waiting on a TolkBot PR would sit red. Use --strict when you want completeness enforced anyway.
Placeholder integrity
A translation that drops an interpolation token is a runtime bug, not a style problem: "Hei {name}" rendered as "Hei" ships a broken string. Validation compares the tokens in each base string against its translation and fails when they diverge.
error "cart.total" in "nb": "{count}" is missing from the translation (relative to "en").
placeholder-mismatch — messages/nb.json · cart.total
Reordering is fine — languages put arguments in different places, and only the set of tokens is compared. The number of braces is part of the token: under i18next {{name}} interpolates and {name} is literal text, so losing a brace is a dropped placeholder.
The syntaxes recognized are {name}, {{name}}, %{name}, printf-style %s / %d / %1$s / %@, component tags such as <0>…</0>, and i18next nesting $t(key).
ICU plurals follow the target language, not the source. A plural's messages are translated, and its branches are the ones the target language needs — English has one and other, Polish one, few, many and other, Japanese only other — so a translation may have more or fewer branches than the base. The argument name, every =0-style branch and the # that prints the number must survive; a branch that only ever means one number, like Arabic two, may say it in words. A plural that lacks a form its language needs is a warning, not an error: it still renders, using other.
These are the same checks TolkBot runs on every translation it writes, so validation in your CI and TolkBot's own pipeline agree on what a broken string is.
Example
$ tolkbot validate
✗ Validation failed — 1 error(s), 1 warning(s)
12 json file(s), 340 keys
Locales: en, es, nb (base: en)
Pattern: messages/{locale}.json
warning Locale "es" is missing 3 key(s) present in "en": settings.title, …
missing-keys
error "cart.total" in "nb": "{count}" is missing from the translation (relative to "en").
placeholder-mismatch — messages/nb.json · cart.total
In CI
Validation needs no credentials, so a workflow step is just the command:
- name: Validate translations
run: npx tolkbot validate
Machine-readable output for a step that post-processes findings:
tolkbot validate --json
{
"valid": false,
"strict": false,
"stats": {
"filesChecked": 12,
"totalKeys": 340,
"format": "json",
"baseLocale": "en",
"locales": ["en", "es", "nb"],
"pattern": "messages/{locale}.json"
},
"counts": { "error": 1, "warning": 1, "info": 0 },
"issues": [
{
"level": "error",
"rule": "placeholder-mismatch",
"message": "\"cart.total\" in \"nb\": \"{count}\" is missing from the translation (relative to \"en\").",
"file": "messages/nb.json",
"locale": "nb",
"key": "cart.total"
}
]
}
Each issue carries a stable rule identifier, so a consumer can filter on it without matching against the message text.
When to validate
Run validation after:
- Translating with
tolkbot translate - Manually editing translation files
- Adding new keys to your base locale
- Before committing translation changes — particularly when a coding agent wrote them