#!/usr/bin/env node // Checks the translations. Text is keyed by label: tr('area.some_label') in src/ and data-i18n="…" // (data-i18n-aria-label, data-i18n-title) in src/index.html, with the English in src/i18n/en.js. // // node scripts/i18n-check.js [lang ...] [--summary FILE] [--fix] (default: every site/i18n/*.js) // // English: every label the code uses is defined, every defined label is used, labels look like // `area.words`, and the English left in the static markup matches en.js. // Each translation: nothing missing, nothing stale, and every entry keeps the {placeholders}, HTML tags and // plural forms of its English. Every dictionary is sorted, one entry per line (--fix sorts them), each // language is offered in the game and cached for offline play. --summary appends a Markdown coverage table // (the CI job writes it to the run's summary page). const fs = require('node:fs'); const path = require('node:path'); const D = require('./lib/dict'); const { CALL } = require('./legacy/labels'); const SITE = path.join(__dirname, '..', 'site'); // The development page: it has every label, the agent's (src/agent/) too. const page = () => require('./lib/page').assemble({ dev: true }).html; const LABEL = /^[a-z0-9_]+(\.[a-z0-9_]+)+$/; // The labels the game uses, with problems in how they are used. function sourceLabels(html) { const labels = new Set(), problems = []; const scripts = [...html.matchAll(/