DevelopAnalyses
@holtkeeper/i18n
Translation gaps of a repository: keys missing per locale, keys only some locales have, empty or untranslated values, placeholder and plural mismatches, keys used in code but missing from the base locale, and keys nothing uses. Produces serializable I18nData, an i18n analysis kind that renders it as a universal Report, and the i18nAnalyzer.
Pipeline
Section titled “Pipeline”- Catalog files come through
CatalogFiles { list(glob?), read(file) }.diskCatalogFiles(dir)reads a checkout (skipping dot directories,node_modules,dist, …). A translation platform API (Crowdin, Lokalise, Tolgee) can implement the same contract. CatalogSource— one module per format, eachmatches(file),locate?(file),parse(text), and optionallyinsert(text, inserts, order)/remove(text, keys):jsonSource()— i18next / react-i18next / vue-i18n / formatjs: nested or flat keys,{ id: { defaultMessage } }, Chrome{ message }, compiled formatjs ASTs. Edits keep indentation,": "spacing, CRLF and key order.yamlSource()—Bun.YAML, Railsru:roots unwrapped. Read-only.poSource()— gettextmsgctxt(keyctx\u0004id),msgid_plural/msgstr[n],#, fuzzy,Plural-Forms. Added entries are marked#, fuzzy.propertiesSource()— Java/Kotlin bundles;messages.propertiesis the default (und) locale, mapped to the base locale. Tool config files (sonar-project,gradle,local,application,bootstrap,log4j,logging,jdbc,hibernate,flyway,config,version, … with any-profile/.suffix) never match; a locale suffix (settings_fr.properties) still does.
- Discovery — without layers,
detectCatalogsfinds catalogs by layout (locales/<lng>/<ns>.json,<lng>.json,public/locales/...,<lng>/LC_MESSAGES/<domain>.po,messages_<lng>.properties); JSON/YAML count only under a translation directory or with at least two locales; a.propertiesfile without a locale (messages.properties) counts only under a translation directory (i18n/,lang/,messages/, …) or next to a localized sibling (messages_de.properties).configBaseLocalereadssourceLocale/defaultLocale/fallbackLngfromi18next.config,next-i18next.config,i18n.ts,lingui.config,next.config,nuxt.config.chooseBaseLocalethen picks: option → config → the locale with the most shared keys (enwins within 5%) →en. - Layers (optional) — catalogs merged in order from several places, later layers overriding earlier ones per key; see below.
- Usage —
scanSourceruns ast-grep over JS/TS/TSX (regex for Vue/Svelte/Astro/HTML) for thefunctionspatterns:t,i18n.t,$t,this.$t,useTranslation().t,<Trans i18nKey>,<FormattedMessage id>,formatMessage({ id }),intl.formatMessage. Static keys (withns:keyand{ ns }) are matched against base keys (a key that prefixes nested keys uses them all); computed keys are dynamic usages, and their static prefix (`errors.${code}`→errors.) keeps keys under it from being reported unused. analyzeCatalogs— pure. Compares every locale with the base: missing, extra, empty / fuzzy / identical-to-base (looksTranslatableskips short tokens, acronyms, brand-like words, URLs), placeholders ({{name}}, ICU{name}and{n, plural, ...},%s/%1$s,<0>/<b>tags), plural forms by CLDR category (embedded table for en, ru, uk, pl, de, fr, es, it, pt, tr, ja, zh, ko, ar, he, cs;Intl.PluralRulesotherwise) for i18next_one/_few/...keys and ICU plurals, and gettext form counts. Insuggestmode it also produces changes.analyzeI18nwires everything;i18nAnalyzeris theAnalyzer(kind: 'i18n',scope: 'repo',needs: { checkout: true });appliesToruns it only on repositories with a source fileisSourceFileaccepts anywhere in the tree, so a Go service with its UI inweb/is analyzed and a Go service without one is skipped.
Options
Section titled “Options”{ mode: 'report' | 'suggest', // default report: no changes locales?: { base?, required?, optional?, ignore? }, baseLocale?: string, // flat alias of locales.base (--base-locale) layers?: [{ id, repo?: 'forge:path', ref?, files, format?: 'json'|'yaml'|'po'|'properties'|'auto', namespace? }], write?: [{ keys?: globs, namespaces?: string[], layer }], functions?: string[], ignoreKeys?: string[], fill: 'todo' | 'base' | 'empty', // default todo marker: string, // default 'TODO: ' __checkouts?: { 'forge:path': '/abs/dir' },}Required locales are expected even without files (all keys missing). Optional locales are reported but left out of the average completeness and get no changes. Ignored locales are skipped.
Layers
Section titled “Layers”Translations often live in a shared repository: common translations plus a folder per project, combined with files of the project itself:
layers: [ { id: 'common', repo: 'work:i18n/translations', ref: 'main', files: 'common/{locale}/{namespace}.json' }, { id: 'game', repo: 'work:i18n/translations', files: 'games/{repoName}/{locale}/{namespace}.json' }, { id: 'local', files: 'src/locales/{locale}.json', namespace: 'game' },],write: [{ namespaces: ['ui'], layer: 'common' }, { keys: 'local.*', layer: 'local' }, { layer: 'game' }],filestemplates (compileTemplate, pure):{locale},{namespace},{repo}(analyzed repository path),{repoName}(its last segment),{group}(path without it),*,**. Without{locale}the locale comes from the path layout; without{namespace}the layer’snamespace(ordefault) applies. Layers merge per namespace.- A layer without
repo(or with the analyzed repository) reads the analyzed checkout. Other repositories must be checked out by the runner:requiredCheckouts(options, repo)lists{ repo, ref? }once per repository, and the runner passes their directories asoptions.__checkouts(--checkout forge:path=/abs/dir, comma-separated for several). A missing checkout is an error. Source code is always scanned in the analyzed checkout. - An external layer whose template does not use
{repo}/{repoName}is shared: its unused keys are informational (other projects use them) and never removed. writerules route missing keys; the first rule whose criteria all match wins; default is the last layer having files of the namespace. Missing locale files are created when the template has no globs.
Changes
Section titled “Changes”suggest mode only, all confidence: 'review', source: 'i18n':
i18n:missing:[forge:path:]<file>— one per catalog file: missing keys (and missing i18next plural variants) copied from the base withfill, placed next to the nearest sibling in base order, as one whole-filereplace(exactoldText) or acreatefor a new file.i18n:unused:[forge:path:]<bundle>— unused, non-shared keys removed from every locale file of the bundle (empty parent objects too).
Changes to an external layer carry target: { forge, path } of the layer’s repository and repository-relative paths, so accepting opens the merge request there. Both kinds rewrite whole files: accept one and re-run before accepting the other for the same file.
I18nData: baseLocale, mode, layers (LayerInfo), provenance (base keys: effective layer and every layer defining it), overrides (keys a later layer redefines, per locale), formats, bundles, locales (LocaleStats with completeness %), keys, missing (with write layer and file), extra, untranslated, placeholders, plurals, usage (files, references, missingInBase with locations, unused with layer and shared, dynamic), changes. i18nDataSchema validates uploads.
Report
Section titled “Report”Metrics: locales, keys, average completeness, missing, untranslated, unused (own; shared ones in the hint), placeholder errors, plural gaps, used-but-not-in-base; all with deltas against the previous record.
Sections: Completeness (bar chart and table per locale with change, catalogs table, a note when layers live elsewhere), Layers (merge order, overrides of shared keys as info issues, key provenance; only with several layers), Missing keys (key × locale table with write layer and new marks, missing per layer and locale, untranslated values, keys only in non-base locales), Placeholders and plurals (issues), Usage (missing-in-base issues with locations, unused keys, shared keys this project does not use, dynamic usages), Suggested changes (changes block, applicable).
Without any catalog the report says no translation catalogs were found: a single catalogs: 0 metric, a Completeness note and no Usage section, since neither coverage nor the usage check ran.
Limitations
Section titled “Limitations”- YAML catalogs are read-only (no changes); JSON with comments (JSONC/JSON5) is not parsed.
- Untranslated detection by identity is heuristic; use
ignoreKeysfor brand names it misses. - Usage matching is lenient about namespaces when calls do not name one (
useTranslation('ns')defaults are not tracked); i18next context suffixes are not modeled. - Checkouts are keyed by repository, not by ref.
- Not refreshed automatically (needs work). The analyzer declares no
refresh, so the freshness sweeper never queues it: nothing reads its records yet besides the generic analysis page (no Translations page, fleet view or agent tool). It runs on demand and from Automation rules. Before turning freshness back on, give the records a consumer, and addrefresh.paths(sources and catalogs) plus a way to rerun when a layer in another repository changes, which the analyzed repository’s head does not show.