Fewer merge conflicts: actions by area, one city per line, sorted dictionaries
- ACT is split by area into game/90-actions/*.js (const ACT in the first file, Object.assign in the rest) - CITY_LL, CITY_NUDGE and LANDS_LL have one entry per line; the id-keyed ones are sorted - site/i18n/*.js are sorted, one entry per line; i18n-check enforces it and --fix (npm run i18n:fix) restores it; scripts/i18n-add.js adds, removes and renames entries in place - scripts/legacy/port-branch.js moves a branch's site/index.html edits into src/ during a merge with main - perf workflow and PR template build the base page with scripts/lib/page.js
This commit is contained in:
parent
67a40942b4
commit
c64b139a86
27 changed files with 9582 additions and 8971 deletions
|
|
@ -2,7 +2,8 @@
|
|||
// Checks a translation against the English text in the game page (assembled from src/): every tr()/trn()/N_() literal and
|
||||
// every data-i18n text, aria-label and title in the static markup should have an entry, no stale entry
|
||||
// should linger, and each translation must keep the {placeholders} and HTML tags of its English key.
|
||||
// Usage: node scripts/i18n-check.js [lang ...] [--summary FILE] (default: every site/i18n/*.js)
|
||||
// Usage: node scripts/i18n-check.js [lang ...] [--summary FILE] [--fix] (default: every site/i18n/*.js)
|
||||
// Dictionaries must also be sorted, one entry per line (scripts/lib/dict.js); --fix sorts them.
|
||||
// It also checks that each language is offered in the game and cached for offline play, and with --summary
|
||||
// appends a Markdown coverage table (the CI job writes it to the run's summary page).
|
||||
const fs = require('node:fs');
|
||||
|
|
@ -65,6 +66,7 @@ function registration(lang) {
|
|||
const m = html.match(/SOT_LANGS=\{([^}]*)\}/);
|
||||
if (!m || !new RegExp(String.raw`(^|[,{\s])${lang}\s*:`).test(m[1])) out.push('not in the language list (SOT_LANGS in src/index.html)');
|
||||
if (!sw.includes(`/i18n/${lang}.js`)) out.push('not cached for offline play (CORE in site/sw.js)');
|
||||
if (!require('./lib/dict').tidy(lang)) out.push('not sorted one entry per line: run npm run i18n:fix');
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +74,12 @@ if (require.main === module) {
|
|||
const args = process.argv.slice(2);
|
||||
const si = args.indexOf('--summary');
|
||||
const summary = si >= 0 ? args.splice(si, 2)[1] : null; // append a Markdown table here (CI: $GITHUB_STEP_SUMMARY)
|
||||
const fi = args.indexOf('--fix');
|
||||
if (fi >= 0) {
|
||||
args.splice(fi, 1);
|
||||
const D = require('./lib/dict');
|
||||
for (const lang of args.length ? args : D.langs()) { const { header, dict } = D.read(lang); D.write(lang, dict, header); }
|
||||
}
|
||||
const keys = sourceKeys(page());
|
||||
const files = (args.length ? args.map((l) => `${l}.js`) : fs.readdirSync(path.join(SITE, 'i18n')))
|
||||
.map((f) => path.join(SITE, 'i18n', f));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue