Files
wekan/tests/allTranslationCompleteness.test.cjs
T
Lauri Ojansivu 225d875b09 Keep translation regression gates scoped to the completed source catalog
Restore current key order across locale files. Preserve the 2,417-string completion milestone while keeping newer feature work visible in ordinary translation reports. Retain full-catalog placeholder and feature-specific checks, with negative coverage for regressions and hidden backlog.

Thanks to xet7 !
2026-10-02 15:13:42 +03:00

50 lines
2.2 KiB
JavaScript

// The completed catalog predates newer features; keep its no-regression gate.
// Full translation work remains visible through fill-translations.mjs --list.
'use strict';
const assert = require('assert');
const childProcess = require('child_process');
const fs = require('fs');
const path = require('path');
const root = path.resolve(__dirname, '..');
const dataDir = path.join(root, 'imports/i18n/data');
const readJson = file => JSON.parse(fs.readFileSync(file, 'utf8'));
const english = readJson(path.join(dataDir, 'en.i18n.json'));
const englishKeys = Object.keys(english);
const locales = fs.readdirSync(dataDir)
.filter(file => file.endsWith('.i18n.json'))
.filter(file => !/^en(?:[-_]|\.)/.test(file))
.sort();
const { translationTokens: tokens } = require('../releases/translations/placeholder-tokens.mjs');
assert.strictEqual(locales.length, 234,
'the completeness gate covers every registered non-English locale file');
for (const file of locales) {
const locale = readJson(path.join(dataDir, file));
assert.deepStrictEqual(Object.keys(locale), englishKeys,
`${file}: keys and key order must match English`);
for (const key of englishKeys) {
assert.deepStrictEqual(tokens(locale[key]), tokens(english[key]),
`${file}:${key}: placeholder inventory must match English`);
}
}
const fillResult = childProcess.spawnSync(process.execPath, [
path.join(root, 'releases/translations/fill-translations.mjs'),
'--completed-catalog', '--missing',
], { cwd: root, encoding: 'utf8' });
assert.strictEqual(fillResult.status, 0, fillResult.stderr);
const fillOutput = `${fillResult.stdout}${fillResult.stderr}`;
// No unreviewed English placeholders from the completed catalog may return.
// New feature strings remain listed by the default CLI. This is a structural gate;
// the separate audit still tracks wrong-language prose and uncertain repairs.
// Correct native words identical to English are protected per locale with evidence.
assert.strictEqual(fillResult.stdout, '', 'no completed-catalog placeholders may return');
assert.match(fillResult.stderr, /0 language\(s\) still have untranslated strings/);
console.log(`allTranslationCompleteness: ${locales.length} locales passed`);