Files
wekan/tests/allTranslationCompleteness.test.cjs
T
Lauri Ojansivu 39af6aae51 Preserve reviewed Veps and Valencian source-identical vocabulary
Native Veps uses server and Valencian uses errors. Protect these exact per-locale keys from placeholder filling, while testing that prose and other locales remain translatable. Update the completeness guard for the repaired Sardinian wording and reviewed native terms; language fluency review remains separate.

Thanks to xet7.
2026-09-14 16:16:55 +03:00

49 lines
1.9 KiB
JavaScript

'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 tokens = value => [...String(value).matchAll(
/__[A-Za-z0-9_.]+__|%(?:\d+\$)?[A-Za-z%]/g,
)].map(match => match[0]).sort();
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'),
'--missing',
], { cwd: root, encoding: 'utf8' });
assert.strictEqual(fillResult.status, 0, fillResult.stderr);
const fillOutput = `${fillResult.stdout}${fillResult.stderr}`;
// No unreviewed English placeholders remain. This is a structural fill 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 unreviewed placeholders may remain');
assert.match(fillResult.stderr, /0 language\(s\) still have untranslated strings/);
console.log(`allTranslationCompleteness: ${locales.length} locales passed`);