chromex-locale-lint
raw JSON → 0.1.0 verified Fri May 01 auth: no javascript
CLI tool for validating Chrome extension localization files (`_locales/*/messages.json`). Version 0.1.0 is the latest stable release. It checks for missing keys across locales and validates locale directory names against Google Chrome's supported locales list. Integrates easily with CI/CD pipelines, supporting a `--strict` flag to treat warnings as errors. Lightweight alternative to rolling custom locale validation scripts.
Common errors
error Error: Locale directory 'en_US' is not supported by Google Chrome. ↓
cause Using region subtag where only language tag is expected (e.g., en_US instead of en).
fix
Rename directory to 'en' or use a valid BCP 47 tag like 'en-US'? Chrome uses 'en', 'en_US' is invalid. Check Chrome documentation.
error Error: ENOENT: no such file or directory, scandir '_locales/' ↓
cause The --localesDir path is incorrect or the directory does not exist.
fix
Specify correct path: npx chromex-locale-lint --localesDir ./src/_locales
Warnings
gotcha If --localesDir is not specified, defaults to '_locales/' relative to current working directory. Ensure correct path. ↓
fix Use absolute path or relative path from project root: --localesDir ./src/_locales
gotcha --baseLang must exactly match a locale directory name (e.g., 'en' not 'en_US'). Chrome uses BCP 47 tags. ↓
fix Use 'en', 'de', 'ja', etc. See Chrome supported locales.
deprecated Version 0.0.3 introduced updated supported locales list; older v0.0.2 may report false positives for valid locales. ↓
fix Upgrade to >=0.0.3 or apply locale list from Chrome manually.
breaking In version 0.1.0, the --strict flag was added. Previously, warnings did not cause exit code failure. Enabling --strict will break CI builds that ignore warnings. ↓
fix Add --strict argument to maintain same behavior, or update CI to handle exit codes.
Install
npm install chromex-locale-lint yarn add chromex-locale-lint pnpm add chromex-locale-lint Imports
- default wrong
const chromexLocaleLint = require('chromex-locale-lint')correctimport chromexLocaleLint from 'chromex-locale-lint' - runLint (hypothetical)
import { runLint } from 'chromex-locale-lint' - bin wrong
npx chromex-locale-lint --dir ./_localescorrectnpx chromex-locale-lint --localesDir ./_locales --baseLang en
Quickstart
npx chromex-locale-lint --localesDir ./_locales --baseLang en --strict