Files
wekan/tests/romanshTranslationProgress.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

44 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The completed catalog predates newer features; keep its no-regression gate.
// Full translation work remains visible through fill-translations.mjs --list.
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const root = path.resolve(__dirname, '..');
const readLocale = code => JSON.parse(fs.readFileSync(
path.join(root, `imports/i18n/data/${code}.i18n.json`), 'utf8',
));
const english = readLocale('en');
const romansh = readLocale('rm');
const tokens = value => [...value.matchAll(
/__[A-Za-z0-9_]+__|%[0-9$]*[A-Za-z]|%{[A-Za-z0-9]+}|{{[A-Za-z0-9]+}}/g,
)].map(([token]) => token).sort();
const tags = value => [...value.matchAll(/<\/?[A-Za-z][^>]*>/g)]
.map(([tag]) => tag).sort();
const fillResult = spawnSync(process.execPath, [
path.join(root, 'releases/translations/fill-translations.mjs'), '--completed-catalog', '--list', 'rm',
], { cwd: root, encoding: 'utf8' });
assert.equal(fillResult.status, 0, fillResult.stderr);
assert.equal(Object.keys(JSON.parse(fillResult.stdout)).length, 0,
'every actionable Romansh value stays translated');
assert.deepEqual(Object.keys(romansh), Object.keys(english),
'Romansh key order follows the English source');
for (const [key, value] of Object.entries(romansh)) {
assert.deepEqual(tokens(value), tokens(english[key]), `${key}: placeholder inventory`);
assert.deepEqual(tags(value), tags(english[key]), `${key}: HTML tag inventory`);
}
assert.equal(romansh.board, 'Tabella');
assert.equal(romansh.card, 'Carta');
assert.equal(romansh.list, 'Glista');
assert.equal(romansh.settings, 'Parameters');
assert.equal(romansh.delete, 'Stizzar');
assert.equal(romansh['enable-permanent-delete'],
'Activar la stizzada permanenta per l’administratur global');
assert.deepEqual(tokens(romansh['restore-list-swimlanes-done']),
['__remaining__', '__restored__']);
console.log('romanshTranslationProgress: complete locale passed');