mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 21:45:01 -05:00
"1 new problems" glued a number to a plural label, and Data health's "Last Run: ... - 8/31" did not say what was counted. Both are now one translated sentence with the numbers as placeholders: "New problems: 1" and "Checks with findings: 8 / 31", translated into all 244 locales. The menu's "Memory Usage" is "Memory usage" like CPU usage and Disk usage, and broken memory-usage values are corrected: Aymara had an English wrapper, Latvian had Lithuanian, and Dutch, Frisian, Tagalog, Tswana, Yoruba and Hawaiian were split or in the wrong word order. Low confidence: ay, chr, csb, iu, kl, ks, kw, lld, nah, rup, szl, tig, tlh, uz-AR, ve, ve-PP, vo, wa, wal, zgh. Thanks to xet7 !
69 lines
3.6 KiB
JavaScript
69 lines
3.6 KiB
JavaScript
'use strict';
|
|
// Admin Panel / Problems / Summary (2026-11-19, .tools/log/wekan10): "1 new
|
|
// problems" did not agree with its number, Data health's "Last Run: ... - 8/31"
|
|
// did not say what 8 and 31 were, and the menu said "Memory Usage" beside
|
|
// "CPU usage" and "Disk usage". Each label is now one translated sentence with
|
|
// its numbers as placeholders, in every locale.
|
|
// Run: node --test tests/problemsSummaryLabels.test.cjs
|
|
const test = require('node:test');
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const DIR = path.join(ROOT, 'imports/i18n/data');
|
|
const read = rel => fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
const locales = fs.readdirSync(DIR).filter(f => f.endsWith('.i18n.json')
|
|
&& !fs.lstatSync(path.join(DIR, f)).isSymbolicLink());
|
|
const load = f => JSON.parse(fs.readFileSync(path.join(DIR, f), 'utf8'));
|
|
const tokens = s => (s.match(/__[A-Za-z0-9]+__|%\d*\$?[sd]/g) || []).sort();
|
|
const en = load('en.i18n.json');
|
|
|
|
test('the summary counts problems and checks through one sentence each', () => {
|
|
const jade = read('client/components/settings/problemsSummary.jade');
|
|
assert.match(jade, /span\.admin-problem-count \{\{_ 'new-problems-count' count=area\.count\}\}/);
|
|
const js = read('client/components/settings/problemsSummary.js');
|
|
const at = js.indexOf('dataHealthStatus() {');
|
|
const body = js.slice(at, js.indexOf('\n },', at));
|
|
assert.match(body, /TAPi18n\.__\('data-health-checks-found', \{ found: d\.found, checks: d\.checks \}\)/);
|
|
assert.strictEqual(en['new-problems-count'], 'New problems: __count__');
|
|
assert.strictEqual(en['data-health-checks-found'], 'Checks with findings: __found__ / __checks__');
|
|
assert.strictEqual(en['memory-usage'], 'Memory usage');
|
|
});
|
|
|
|
test('negative: no bare number is glued to a label any more', () => {
|
|
const jade = read('client/components/settings/problemsSummary.jade');
|
|
assert.doesNotMatch(jade, /\{\{area\.count\}\} \{\{_ 'new-problems'\}\}/);
|
|
const js = read('client/components/settings/problemsSummary.js');
|
|
assert.doesNotMatch(js, /\$\{d\.found\}\/\$\{d\.checks\}/);
|
|
});
|
|
|
|
test('every locale has both sentences, in order, with exactly the English placeholders', () => {
|
|
assert.ok(locales.length > 200);
|
|
for (const f of locales) {
|
|
const j = load(f);
|
|
const keys = Object.keys(j);
|
|
for (const [key, anchor] of [['new-problems-count', 'new-problems'],
|
|
['data-health-checks-found', 'data-health-never-run']]) {
|
|
assert.ok(typeof j[key] === 'string' && j[key].trim(), `${f}: ${key}`);
|
|
assert.deepStrictEqual(tokens(j[key]), tokens(en[key]), `${f}: ${key} placeholders`);
|
|
assert.strictEqual(keys.indexOf(key), keys.indexOf(anchor) + 1, `${f}: ${key} after ${anchor}`);
|
|
if (!f.startsWith('en')) assert.notStrictEqual(j[key], en[key], `${f}: ${key} is translated`);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('negative: "Memory usage" is no longer wrong-language or split in these locales', () => {
|
|
const fixed = { lv: 'Atmiņas lietojums', nl: 'Geheugengebruik', fy: 'Unthâldgebrûk',
|
|
tl: 'Paggamit ng memorya', tn: 'Tiriso ya segopotso', yo: 'Lílo ìrántí' };
|
|
for (const [tag, value] of Object.entries(fixed)) {
|
|
assert.strictEqual(load(`${tag}.i18n.json`)['memory-usage'], value, tag);
|
|
}
|
|
assert.doesNotMatch(load('ay.i18n.json')['memory-usage'], /Memory|Aymar aruna/);
|
|
// Latvian had Lithuanian text.
|
|
assert.doesNotMatch(load('lv.i18n.json')['memory-usage'], /Atminties|naudojimas/);
|
|
for (const f of locales.filter(n => n.startsWith('en'))) {
|
|
assert.strictEqual(load(f)['memory-usage'], 'Memory usage', f);
|
|
}
|
|
});
|