#!/usr/bin/env node // Checks a translation against the English text in site/index.html: 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) // 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'); const path = require('node:path'); const vm = require('node:vm'); const SITE = path.join(__dirname, '..', 'site'); const LIT = String.raw`'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"|\x60(?:[^\x60\\$]|\\.|\$(?!\{))*\x60`; const CALL = new RegExp(String.raw`(? vm.runInContext(s, CTX); // English keys used by the game. Calls whose text is not a literal cannot be checked and are skipped. function sourceKeys(html) { const keys = new Set(); const scripts = [...html.matchAll(/