Ship short ids instead of labels; checker, tests and docs for labels
The build swaps every label for a short id in the shipped page, the inlined English and the translation files (scripts/lib/compile-labels.js). Labels passed to N_() stay whole because saves keep them. Against 1.33: page +4% gzipped (321 -> 335 KB), translations -40% (it.js 143 -> 85 KB); routing, day, panels, dashboard, map and boot time unchanged. - i18n-check rejects labels the build cannot see (outside tr/trn/N_) - tests/pages.test.js plays the shipped page in English, Italian and French - docs/adr/0003, add-strings skill, ARCHITECTURE, README, CONTRIBUTING, CLAUDE.md describe labels
This commit is contained in:
parent
9043af5ab0
commit
0057e74472
14 changed files with 253 additions and 63 deletions
|
|
@ -152,3 +152,11 @@ for (const lang of ['en', 'it', 'pt', 'fr']) {
|
|||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
test('the translation check catches labels the build could not see, and English-keyed calls', () => {
|
||||
const { sourceLabels } = require('../scripts/i18n-check');
|
||||
const { problems, labels } = sourceLabels("<html><body><script>const x='pnis.foo_bar';tr('pnis.ok_label');N_('pnis.kept');trn('{n} POP','{n} POPs',n)</script></body></html>");
|
||||
assert.ok(labels.has('pnis.ok_label') && labels.has('pnis.kept'));
|
||||
assert.ok(problems.some((p) => p.includes('pnis.foo_bar') && p.includes('N_()')), 'a bare label');
|
||||
assert.ok(problems.some((p) => p.includes('not a label')), 'English text where a label belongs');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue