@json-translate/check
v0.1.1
Published
Validate JSON locale files for missing keys and placeholder drift.
Maintainers
Readme
@json-translate/check
Validate translated JSON locale files before they break your app.
@json-translate/check is a small dependency-free CLI for i18n and localization workflows. It compares translated JSON files against a source locale and fails when structure or placeholders drift.
Usage
npx @json-translate/check --source locales/en.json --target locales/fr.json --target locales/de.jsonYou can also pass comma-separated targets:
npx @json-translate/check -s locales/en.json -t locales/fr.json,locales/de.jsonChecks
- Target JSON parses successfully
- Source keys are not missing from target files
- Unexpected extra keys are reported
- Placeholders are preserved across source and target strings
Placeholder patterns checked:
{name}{{count}}${value}%s,%d,%i,%f
Example Output
FAIL locales/fr.json
missing key: nav.save
extra key: legacy.banner
placeholder missing at greeting: {name}GitHub Actions
name: Locale checks
on:
pull_request:
jobs:
json-locales:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate translated JSON locale files
run: npx @json-translate/check --source locales/en.json --target locales/fr.json,locales/de.jsonExit Codes
0: no validation issues1: validation issues found2: usage error or JSON read/parse error
Where It Fits
Use JSON Translate to create draft translations, then run this CLI before merging translated locale files.
- Translate JSON files online: https://www.json-translate.com/?utm_source=cli&utm_medium=devtool&utm_campaign=json_translate_check
- CLI guide: https://www.json-translate.com/json-translate-check
- i18next workflow: https://www.json-translate.com/translate-i18next-json
Common Use Cases
- i18next locale files
- next-intl JSON files
- React Intl message catalogs
- FormatJS JSON catalogs
- Vue I18n locale files
- Chrome extension
_locales/*/messages.jsonfiles
