mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
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 !
50 lines
2.2 KiB
JavaScript
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`);
|