Add Italian translation and a language switch
English stays the source text and the default. Player-facing strings go
through tr()/trn(), which look the English up in a per-language dictionary
(site/i18n/<lang>.js) and fall back to it unchanged. The dictionary is only
loaded when the game runs in that language. The language follows the
browser on the first visit and can be switched under Settings or on the
title screen; the choice is remembered.
- site/i18n/it.js: complete Italian translation (~1900 entries)
- scripts/i18n-check.js / npm run i18n:check: lists missing or stale entries
and translations that drop a {placeholder} or HTML tag
- tests/i18n.test.js: language selection, fallback, dictionary integrity,
and a tour of every screen, failure and event in English and Italian
This commit is contained in:
parent
37a83c2b3f
commit
04eb32e0a5
8 changed files with 3165 additions and 1054 deletions
|
|
@ -23,6 +23,9 @@ function load(opts = {}) {
|
|||
// Seed before the game script runs, so nothing random happens at load time either.
|
||||
if (opts.seed !== false) { let r = opts.seed || 12345; window.Math.random = () => { r = (r * 16807) % 2147483647; return r / 2147483647; }; window.__reseed = (n) => { r = n; }; }
|
||||
for (const [k, v] of Object.entries(opts.storage || {})) window.localStorage.setItem(k, v);
|
||||
if (opts.navigatorLanguage) Object.defineProperty(window.navigator, 'language', { value: opts.navigatorLanguage });
|
||||
// A non-English game: jsdom does not fetch the dictionary script, so register it up front.
|
||||
if (opts.lang) { window.localStorage.setItem('sot-lang', opts.lang); window.eval(fs.readFileSync(path.join(__dirname, '..', 'site', 'i18n', opts.lang + '.js'), 'utf8')); }
|
||||
window.Path2D = class { moveTo() {} lineTo() {} quadraticCurveTo() {} bezierCurveTo() {} arc() {} rect() {} closePath() {} };
|
||||
// A recording 2D context, so draw code really runs under test (jsdom has no canvas).
|
||||
const fake = () => { const calls = { n: 0 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue