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

122 lines
5.4 KiB
JavaScript

// 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 tswana = readLocale('tn');
const tokens = value => [...value.matchAll(
/__[A-Za-z0-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',
'tn',
], { cwd: root, encoding: 'utf8' });
assert.equal(fillResult.status, 0, fillResult.stderr);
assert.equal(Object.keys(JSON.parse(fillResult.stdout)).length, 0,
'every actionable Tswana value stays translated');
for (const [key, value] of Object.entries(tswana)) {
if (value !== english[key]) {
assert.deepEqual(tokens(value), tokens(english[key]),
`${key}: locale-wide placeholder inventory`);
}
assert.deepEqual(tags(value), tags(english[key]),
`${key}: locale-wide HTML tag inventory`);
}
assert.equal(tswana.accept, 'Amogela');
assert.deepEqual(tokens(tswana['activity-changedTitle']), ['%s', '%s']);
assert.deepEqual(tokens(tswana['act-deleteCard']),
['__board__', '__card__', '__list__', '__swimlane__']);
assert.match(tswana['act-addAttachment'], /se se tshwaraganeng/);
assert.match(tswana['act-addChecklist'], /lenaane la tlhatlhobo/);
assert.match(tswana['board-members-same-org-only'], /Mokgatlhong/);
assert.match(tswana['board-members-same-team-only'], /Setlhopheng/);
assert.deepEqual(tokens(tswana['act-moveCardToOtherBoard']),
['__board__', '__card__', '__list__', '__oldBoard__', '__oldList__',
'__oldSwimlane__', '__swimlane__']);
assert.deepEqual(tokens(tswana['activity-imported']), ['%s', '%s', '%s']);
assert.equal(tswana['allboards.workspaces'], 'Mafelo a tiro');
assert.match(tswana['allboards.edit-workspace-icon'], /markdown/);
assert.deepEqual(tokens(tswana['activity-dueDate']), ['%s', '%s']);
assert.match(tswana['list-width-error-message'], /palogotlhe ya bonnye dipiksele di le 200/);
assert.doesNotMatch(tswana['list-width-error-message'], /270/);
assert.match(tswana['set-swimlane-height-value'], /dipiksele/);
assert.equal(tswana['convertChecklistItemToCardPopup-title'],
'Fetolela go karata');
assert.deepEqual(tokens(tswana['and-n-other-card']), ['__count__']);
assert.deepEqual(tokens(tswana['avatar-too-big']), ['__size__']);
assert.deepEqual(tags(tswana['board-private-info']),
['</strong>', '<strong>']);
assert.match(tswana['board-background-image-url'], /URL/);
assert.deepEqual(tags(tswana['board-public-info']),
['</strong>', '<strong>']);
assert.deepEqual(tokens(
tswana['board-open-and-move-between-remaining-and-workspaces']),
['__workspaces__']);
assert.match(tswana['enter-zoom-level'], /50-300%/);
assert.deepEqual(tokens(tswana['card-comments-title']), ['%s']);
assert.match(tswana['cardStartPlanningPokerPopup-title'], /Planning Poker/);
assert.match(tswana['editPokerEndDatePopup-title'], /Planning Poker/);
assert.equal(tswana['importSwimlanePopup-title'], 'Tlisetsa tsela');
assert.match(tswana['addBoardOrgPopup-title'], /Mokgatlho/);
assert.match(tswana.casSignIn, /CAS/);
assert.match(tswana['map-to-existing-user-desc'], /ditetla/);
assert.match(tswana['font-preview-text'], /0123456789/);
assert.equal(tswana['restoreArchivedListToSwimlanePopup-title'],
'Busetsa lenaane mo tseleng');
assert.equal(tswana['color-black'], 'ntsho');
assert.equal(tswana['color-red'], 'khibidu');
assert.match(tswana['card-aging-days'], /3/);
assert.match(tswana['close-board-pop'], /Polokelo/);
assert.equal(tswana['color-white'], 'tshweu');
assert.equal(tswana['color-yellow'], 'serolwana');
assert.match(tswana['confirm-move-list-to-swimlane'], /tseleng/);
assert.doesNotThrow(() => JSON.parse(tswana['copyManyCardsPopup-format']));
assert.deepEqual(tokens(tswana['email-invite-text']),
['__board__', '__inviter__', '__url__', '__user__']);
assert.deepEqual(tokens(tswana['email-resetPassword-text']),
['__url__', '__user__']);
assert.match(tswana['error-json-malformed'], /JSON/);
assert.match(tswana['error-csv-schema'], /CSV.*TSV/);
assert.match(tswana['export-card-pdf'], /PDF/);
assert.match(tswana['export-card-excel'], /Excel/);
assert.match(tswana['export-card-field-board-info'], /Boto.*Lenaane.*Tsela/);
assert.match(tswana['filter-due-tomorrow'], /kamoso/);
assert.deepEqual(tokens(tswana['import-board-instruction-issues']),
['__endpoint__', '__sourceName__']);
assert.match(tswana['advanced-filter-description'], /F1 == \/Tes\.\*\/i/);
assert.match(tswana['import-board-instruction-jira'], /automationRules/);
assert.match(tswana['import-trello-zip-file-hint'], /\.zip.*\.json/);
assert.equal(tswana['select-none'], 'Se tlhophe sepe');
assert.deepEqual(tokens(tswana['restore-list-swimlanes-done']),
['__remaining__', '__restored__']);
assert.match(tswana['sandstorm-remove-member-warning'], /tetla/);
assert.equal(tswana['history-change-restored'], 'E buseditswe');
console.log('tswanaTranslationProgress: complete locale passed');