From 42711456e2cb40f52f211db8b380a363b38be680 Mon Sep 17 00:00:00 2001 From: Danilo Carbonaro <107484701+daniloctdev@users.noreply.github.com> Date: Sat, 24 Oct 2026 15:25:14 +0200 Subject: [PATCH] Tidy the i18n layer after review - Badges that react to sharks, anchors, crocodiles and llamas read the English text of the incident again, so they unlock in every language. - Scenario names are looked up when shown, so they follow a language switch. - Fall back to English (and lang="en") when the dictionary did not load, and version the dictionary URL so a release never pairs with a stale one. - Share the segmented-button helper between settings and the title screen, merge keys that only differed in a placeholder name, and slim the check script. - Tests: guard the hooks the tour patches into fireFailure/fireEvent, and cover the dictionary fallback and the scenario name. --- scripts/i18n-check.js | 26 ++++++++++-------------- site/i18n/it.js | 4 ---- site/index.html | 47 ++++++++++++++++++++++++------------------- tests/i18n.test.js | 20 ++++++++++++++++-- 4 files changed, 55 insertions(+), 42 deletions(-) diff --git a/scripts/i18n-check.js b/scripts/i18n-check.js index af224c4..17754f9 100644 --- a/scripts/i18n-check.js +++ b/scripts/i18n-check.js @@ -9,25 +9,23 @@ 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.runInNewContext(s); +const CALL = new RegExp(String.raw`(? vm.runInContext(s, CTX); -// English keys used by the game, plus calls whose text is not a literal (those cannot be checked). +// 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(), dynamic = []; + const keys = new Set(); const scripts = [...html.matchAll(/