Skip to content

comvi check

View .md

Compare every local catalog with the source locale and list what each translation lacks or gets wrong: missing keys, parameters, plural and select branches, tags. The command reads only files on disk, so it runs with no API key, no .comvirc.json, no .env and no network.

Terminal
comvi check [options]
Check src/i18n against English
npx comvi check --path src/i18n --source en

Settings with a config equivalent use the flag first, then .comvirc.json when one is found, then the default. With no config file the command reads ./src/locales with the {namespace}/{languageTag}.json layout, where the default namespace lives at the root as {languageTag}.json, and compares every catalog with en.

Option Default Meaning
-c, --config <path> nearest .comvirc.json, if any Config file to read. A path that does not exist exits 4
-p, --path <path> translationsPath, else ./src/locales Translations directory
--file-template <template> fileTemplate, else {namespace}/{languageTag}.json File layout: one {languageTag}, at most one {namespace}, ending in .json or .{extension}
-s, --source <locale> sourceLocale, else en Locale every other catalog is compared with
-l, --locale <locales> locales, else every catalog found Comma-separated locales to report on
-n, --ns <namespaces> namespaces, else every namespace found Comma-separated namespaces to compare
--format <format> text text or json
--identical check.identical, else off Warn when a translation equals its source
--strict check.strict, else off Fail on warnings too
--no-fail off Exit 0 even when there are findings

Locale names match catalogs ignoring case and _ versus -: -l pt-BR checks pt-br.json and reports it as pt-br, and a locale repeated in --locale is checked once; a duplicate in the config’s locales exits 4. The source catalog is always read and never compared with itself: -l de reads en and de and compares de only. A locale or namespace in the filter that has no catalog exits 4 with Unknown locales: … or Unknown namespaces: …, because a typo there would hide the catalogs it was meant to select. So does a source name that matches two catalogs, such as pt-BR.json and pt_br.json. For plural rules a _ in a locale name is read as -, so pt_BR.json is judged by the rules of pt-BR and still reported as pt_BR.

A template without {namespace}, such as {languageTag}.json or messages.{languageTag}.json, reads one file per locale and puts its keys in the default namespace. check accepts that layout in fileTemplate too, but pull and push reject a .comvirc.json whose template has no {namespace} with exit 4, so in a config the three commands share, pass it with --file-template instead. Nested objects in a file are read as dotted keys, the way comvi push reads them.

Rule Severity Reported when
missing error A source key is absent from the target, or its value there is empty or whitespace only
stale warning The target has a key the source does not
emptySource error The source value is empty or whitespace only. Reported once, for the source, and the key is compared no further
params error The parameter names differ, as in Hello {name} against Hallo
plural error or warning A plural or selectordinal group has no other branch (missing-other, error), or a selector its locale does not have, such as few in German (invalid-selector, error). A category the locale has and the message leaves out is missing-category, a warning
select error A select argument has different selectors in source and target
tags error The source uses tags and the target’s tag names differ. When the source has no tags, target tags are not compared
unbalancedTags warning Tag markup that renders as literal text: a tag opened and never closed, closed and never opened, closed out of order, or written after an unclosed {
unsupportedIcu error An argument @comvi/core does not compile: {price, number}, {when, date, short}, {n, plural} without a choice list, a choice list that does not parse, or a plural or selectordinal exact value other than = and a decimal number (=x, =1e3, =.5, =+1, =Infinity)
identical warning, opt-in The target value equals the source value. On with --identical or check.identical

An error fails the run; a warning fails it only with --strict or check.strict. --no-fail keeps the exit code at 0 either way, and the report still says ok: false. Problems in the source message itself (emptySource, and plural, unbalancedTags or unsupportedIcu on the source side) are reported once, in their own source section, however many targets there are. The source’s plural groups are judged against the source locale’s rules, so a source {n, plural, one {a}} with no other fails the run even with every translation in place. A whitespace-only translation counts as missing, which is stricter than @comvi/core: at runtime it renders as blank text.

Every non-blank source message is read with the ICU grammar @comvi/core compiles, also for apps on the default compiler, and so is every target message with a non-blank source and target: a catalog that later adopts compiler: icuCompiler must already be well-formed. Stale keys and keys reported as missing are not scanned. The scanner is the one @comvi/vite-plugin generates parameter types from.

Plural categories come from Intl.PluralRules of the Node that runs the command: cardinal rules for plural, ordinal rules for selectordinal. The data is CLDR, so results follow the Node version. French, Spanish, Italian and Portuguese have a many category there, so a one/other plural in those locales gets a missing-category warning, and --strict makes the run fail on it; the JSON still counts it under warnings. Each plural or selectordinal group is judged on its own, so a message that writes {n, plural, …} twice needs other in both. An exact selector is = and a decimal number (=0, =-1, =1.5), the only form @comvi/core compiles, and is valid in every locale. Any other = value makes core refuse the whole argument, so check reports it as unsupportedIcu with the argument type plural or selectordinal.

For a locale code Intl does not know, source or target, only the other branch is checked; categories are not judged. The text output marks it (no Intl plural rules: only `other` checked) and the JSON sets localeUnknown: true. When either side of a key has an unsupported argument, that key’s parameters, select and plural branches are not compared, because the scan of the message is incomplete. Keys outside the default namespace are reported as namespace:key. ICU syntax is on the ICU reference and tags on Tag interpolation.

Terminal
comvi check ./src/locales source=en 2 locales 2 keys
en source: ok
de 1 stale, 1 params, 2 plural
stale de:old
params de:hello source {name} target {}
plural de:bye {n} missing-other other
plural de:bye {n} invalid-selector few, many
✗ 1 stale, 1 params, 2 plural — exit 1

The first line names the directory, the source, the number of locales including the source and the number of source keys. The source gets one line for its own findings, such as en source: 1 plural, each target locale one line of counts, or ok, then every finding gets a line, and the last line gives the totals and the exit code. Progress and errors go to stderr and the report to stdout, so --format json > report.json writes the JSON alone.

report.json
{
"version": 1,
"source": {
"locale": "en",
"emptySource": [],
"plural": [],
"unbalancedTags": [],
"unsupportedIcu": [],
"localeUnknown": false
},
"translationsPath": "./src/locales",
"fileTemplate": "{namespace}/{languageTag}.json",
"keys": 2,
"locales": {
"de": {
"missing": [],
"stale": [
"old"
],
"params": [
{
"key": "hello",
"source": [
"name"
],
"target": []
}
],
"plural": [
{
"key": "bye",
"argument": "n",
"problem": "missing-other",
"categories": [
"other"
]
},
{
"key": "bye",
"argument": "n",
"problem": "invalid-selector",
"categories": [
"few",
"many"
]
}
],
"select": [],
"tags": [],
"unbalancedTags": [],
"unsupportedIcu": [],
"identical": [],
"localeUnknown": false
}
},
"summary": {
"missing": 0,
"stale": 1,
"emptySource": 0,
"params": 1,
"plural": 2,
"select": 0,
"tags": 0,
"unbalancedTags": 0,
"unsupportedIcu": 0,
"identical": 0
},
"errors": 3,
"warnings": 1,
"ok": false
}

The document carries "version": 1 and a fixed key order. source holds the source locale, its own findings and its localeUnknown; locales holds one entry per target with target findings only. missing, stale, emptySource and identical list keys; the other rules list objects. A params or tags finding has key, source and target; a select finding adds argument. A plural finding has key, argument, problem (missing-other, invalid-selector or missing-category) and the categories concerned. unbalancedTags has key and tags; unsupportedIcu has key and argumentType. summary counts each rule across the source and every target, and ok is false on any error, or on any warning with --strict.

check uses the codes every CLI command uses. It never contacts the platform, so it never exits 2 or 3.

Code Meaning
0 No failing findings, or --no-fail
1 Findings that fail the run: an error, or a warning with --strict. Also an unexpected failure of the check itself
4 Invalid input, before any finding is reported. See the list below

Each of these exits 4:

  • Config: --config names a file that does not exist or a directory, or .comvirc.json is malformed or has a field the config does not have, the legacy languages included.
  • Flags: an unknown option, an option without its value, a --format other than text or json, an empty --source, --locale or --ns, or a malformed --file-template.
  • Catalogs: the translations directory is a file or cannot be listed, a catalog cannot be read or is not JSON, holds a non-string value or a key defined both flat and nested, or two files hold the same locale and namespace.
  • Locales: a filtered locale or namespace has no catalog, or the source locale matches no catalog or more than one. A translations directory that does not exist has no source catalog, so it exits 4 this way.

check differs from comvi pull and comvi push in two ways. A missing .comvirc.json is not an error: the command runs on the defaults, where pull and push exit 4. And check loads no .env file and never reads COMVI_API_KEY or COMVI_API_BASE_URL, so a CI job needs no secret, and --dotenv has no effect on it. With no --source and no sourceLocale, a directory without an en catalog exits 4 and asks you to name the source with either of them.

.github/workflows/ci.yml
- run: npx comvi check --path src/i18n --source en

The step fails on any error and passes on warnings unless check.strict is set. Add --strict to fail on warnings too (stale keys, unbalanced tags, plural categories left out), or --format json with --no-fail to keep the report as a build artifact without failing the job. --no-fail covers findings only: invalid input still exits 4.