waybetter-for-x/scripts/i18n-check.mjs
2026-09-30 23:01:13 +00:00

23 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
// Checks every locale catalog (docs/TRANSLATING.md) and the files generated from them. Part of
// `bun run test`. This is `waybetter i18n check` (the framework's CLI, waybetter/packages/waybetter/
// cli/i18n.mjs) with this repository's waybetter.i18n.json: file shape, keys that English does not
// have, ICU syntax, placeholder parity with English, plural forms each language needs, no markup or
// control characters, length warnings; the app's catalogs and the framework's.
//
// node scripts/i18n-check.mjs check (exit 1 on errors)
// node scripts/i18n-check.mjs --write also regenerate apps/desktop/locales/languages.json and
// the native localization files (macOS, Linux)
// node scripts/i18n-check.mjs --verbose list every warning (untranslated and long messages)
// node scripts/i18n-check.mjs tr only these locales (plus English)
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { i18nCommand } from '../waybetter/packages/waybetter/cli/i18n.mjs';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
try {
process.exit(await i18nCommand(['check', ...process.argv.slice(2)], { cwd: root }));
} catch (error) {
console.error(`i18n-check: ${error instanceof Error ? error.message : error}`);
process.exit(1);
}