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.
This commit is contained in:
Danilo Carbonaro 2026-10-24 15:25:14 +02:00
parent 04eb32e0a5
commit 42711456e2
4 changed files with 55 additions and 42 deletions

View file

@ -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`(?<![\w$.])(tr|trn|N_)\(\s*(?:(${LIT})(?:\s*,\s*(${LIT}))?)?`, 'g');
const literal = (s) => vm.runInNewContext(s);
const CALL = new RegExp(String.raw`(?<![\w$.])(tr|trn|N_)\(\s*(${LIT})(?:\s*,\s*(${LIT}))?`, 'g');
const CTX = vm.createContext({});
const literal = (s) => 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(/<script>([\s\S]*?)<\/script>/g)].map((m) => m[1]).join('\n');
for (const m of scripts.matchAll(CALL)) {
if (!m[2]) { dynamic.push(scripts.slice(m.index, m.index + 60).split('\n')[0]); continue; }
keys.add(literal(m[2]));
if (m[1] === 'trn' && m[3]) keys.add(literal(m[3]));
}
const { JSDOM } = require('jsdom');
const doc = new JSDOM(html).window.document;
for (const el of doc.querySelectorAll('[data-i18n]')) keys.add(el.textContent);
for (const el of doc.querySelectorAll('[aria-label],[title]')) {
for (const a of ['aria-label', 'title']) if (el.hasAttribute(a)) keys.add(el.getAttribute(a));
}
return { keys, dynamic };
for (const a of ['aria-label', 'title']) for (const el of doc.querySelectorAll(`[${a}]`)) keys.add(el.getAttribute(a));
return keys;
}
function loadDict(file) {
@ -46,26 +44,24 @@ function brokenEntries(dict) {
placeholders(en) !== placeholders(xx) || tags(en) !== tags(xx)).map(([en]) => en);
}
function check(html, dict) {
const { keys, dynamic } = sourceKeys(html);
function check(keys, dict) {
return {
missing: [...keys].filter((k) => !(k in dict)),
unused: Object.keys(dict).filter((k) => !keys.has(k)),
broken: brokenEntries(dict),
dynamic,
};
}
module.exports = { sourceKeys, loadDict, brokenEntries, check };
module.exports = { loadDict, brokenEntries };
if (require.main === module) {
const html = fs.readFileSync(path.join(SITE, 'index.html'), 'utf8');
const keys = sourceKeys(fs.readFileSync(path.join(SITE, 'index.html'), 'utf8'));
const langs = process.argv.slice(2);
const files = (langs.length ? langs.map((l) => `${l}.js`) : fs.readdirSync(path.join(SITE, 'i18n')))
.map((f) => path.join(SITE, 'i18n', f));
let bad = false;
for (const file of files) {
const r = check(html, loadDict(file));
const r = check(keys, loadDict(file));
console.log(`${path.basename(file)}: ${r.missing.length} missing, ${r.unused.length} unused, ${r.broken.length} broken`);
for (const [label, list] of [['missing', r.missing], ['unused', r.unused], ['broken', r.broken]]) {
for (const k of list) console.log(` ${label}: ${JSON.stringify(k)}`);

View file

@ -538,7 +538,6 @@
"Step {n} of {total}":"Passo {n} di {total}",
"Skip tutorial":"Salta il tutorial",
"{name} cache":"Cache {name}",
"PNI with {name}":"PNI con {name}",
"{ix} peering":"Peering {ix}",
"{name} transit":"Transit {name}",
"{city}, your router":"{city}, il tuo router",
@ -590,7 +589,6 @@
"Badges":"Badge",
"Weekly {key}":"Settimanale {key}",
"score {v}":"punteggio {v}",
"done in {n} days":"fatto in {n} giorni",
"not this time":"non stavolta",
"in progress":"in corso",
"Build the internet, one tube at a time":"Costruisci internet, un tubo alla volta",
@ -688,7 +686,6 @@
"Not big enough yet: {list}":"Non sei ancora abbastanza grande: {list}",
"{net} transit · {lag}":"transit {net} · {lag}",
"Add a LAG member, upgrade the port or buy a second upstream.":"Aggiungi un membro al LAG, fai l’upgrade della porta o compra un secondo upstream.",
"{ix} port":"porta {ix}",
"Upgrade the IX port or add a LAG member.":"Fai l’upgrade della porta IX o aggiungi un membro al LAG.",
"PNI with {net}":"PNI con {net}",
"Add a LAG member or upgrade the PNI.":"Aggiungi un membro al LAG o fai l’upgrade del PNI.",
@ -1463,7 +1460,6 @@
"{port} port · {price}/mo":"Porta {port} · {price}/mese",
"{g} of circuits":"{g} di circuiti",
"New circuit":"Nuovo circuito",
"Upgrade 100G <small>{price}/mo</small>":"Passa a 100G <small>{price}/mese</small>",
"Remove port":"Rimuovi porta",
"{port} port <small>{price}/mo</small>":"Porta {port} <small>{price}/mese</small>",
"Fiber from {city}":"Fibra da {city}",

View file

@ -455,8 +455,8 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
<script>
// Language: the player's saved choice, else the browser's, else English. Non-English dictionaries load before the game.
(function(){const langs=window.SOT_LANGS={en:'English',it:'Italiano'};let l=null;try{l=localStorage.getItem('sot-lang');}catch(e){}
if(!Object.hasOwn(langs,l))l=Object.keys(langs).find(k=>k===(navigator.language||'').slice(0,2).toLowerCase())||'en';
window.SOT_LANG=l;document.documentElement.lang=l;if(l!=='en')document.write('<script src="i18n/'+l+'.js"><\/script>');})();
const b=(navigator.language||'').slice(0,2).toLowerCase();if(!Object.hasOwn(langs,l))l=Object.hasOwn(langs,b)?b:'en';
window.SOT_LANG=l;document.documentElement.lang=l;if(l!=='en')document.write('<script src="i18n/'+l+'.js?v=__VERSION__"><\/script>');})();
</script>
<script>
'use strict';
@ -464,8 +464,9 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
English is the source text: tr(text,vars) looks it up in the dictionary that
site/i18n/<lang>.js registered and falls back to the English. trn() picks the singular or plural
form first; N_() only marks text that doubles as an id, so it can be translated where it is shown. */
const LANGS=window.SOT_LANGS||{en:'English'};
const LANG=Object.hasOwn(LANGS,window.SOT_LANG)?window.SOT_LANG:'en';
// English when the dictionary did not load (offline, or a copy without the i18n folder).
const LANGS=window.SOT_LANGS,LANG=window.I18N?.[window.SOT_LANG]?window.SOT_LANG:'en';
document.documentElement.lang=LANG;
const DICT=Object.assign(Object.create(null),window.I18N?.[LANG]);
function tr(s,v){const o=DICT[s]||s;return v?o.replace(/\{(\w+)\}/g,(m,k)=>k in v?v[k]:m):o;}
function trn(one,other,n,v){return tr(n===1?one:other,{n,...v});}
@ -1114,7 +1115,7 @@ function loanTick(d){
l.bal=Math.max(0,l.bal*(1+l.apr/12)-l.pay);l.left--;
if(l.left<=0||l.bal<1){S.loans=S.loans.filter(x=>x!==l);track('loan_repaid');toast(tr('<b>Loan from {bank} paid off!</b><br>They sent a fruit basket. It is mostly bananas.',{bank:esc(BANKS[l.bank].name)}),'good');sfx('coin');}}
// the shark's collectors come by when you are broke
if(S.cash<0&&S.loans.some(l=>BANKS[l.bank].shark)&&Math.random()<0.03){const c=pick(Object.keys(S.pops));const p=S.pops[c];p.down=Math.max(p.down||0,d+1);addInc({type:'shutdown',ref:c,until:d+1,msg:tr('Two very large gentlemen from Loan Shark Telecom Finance unplugged your router in {city} "as a reminder".',{city:CITY[c].name}),cost:0});toast(tr('<b>The loan shark sent a reminder.</b><br>Your POP in {city} is dark until tomorrow.',{city:CITY[c].name}),'bad');sfx('alert');}
if(S.cash<0&&S.loans.some(l=>BANKS[l.bank].shark)&&Math.random()<0.03){const c=pick(Object.keys(S.pops));const p=S.pops[c];p.down=Math.max(p.down||0,d+1);const en=N_('Two very large gentlemen from Loan Shark Telecom Finance unplugged your router in {city} "as a reminder".');addInc({type:'shutdown',ref:c,until:d+1,msg:tr(en,{city:CITY[c].name}),cost:0},en);toast(tr('<b>The loan shark sent a reminder.</b><br>Your POP in {city} is dark until tomorrow.',{city:CITY[c].name}),'bad');sfx('alert');}
// offers: now and then, and much more often when you are in trouble
S.loanOffers=S.loanOffers.filter(o=>o.exp>d);
const broke=S.cash<0;
@ -1126,6 +1127,8 @@ const _rand=Math.random;
Math.random=function(){if(S&&typeof S.rng==='number'){let t=(S.rng=(S.rng+0x6D2B79F5)|0);t=Math.imul(t^t>>>15,1|t);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;}return _rand();};
function isoWeek(dt){const d=new Date(Date.UTC(dt.getFullYear(),dt.getMonth(),dt.getDate()));const n=d.getUTCDay()||7;d.setUTCDate(d.getUTCDate()+4-n);const y0=new Date(Date.UTC(d.getUTCFullYear(),0,1));return {y:d.getUTCFullYear(),w:Math.ceil(((d-y0)/864e5+1)/7)};}
function pathExists(a,b){if(!S.pops[a]||!S.pops[b])return false;const adj={};for(const l of S.links){if(linkDown(l))continue;(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;}
// Looked up rather than read from the save, so it follows a language switch mid-scenario.
const scnName=()=>S.scn.id==='weekly'?tr('Weekly {key}',{key:S.scn.key}):SCN.find(x=>x.id===S.scn.id)?.n||S.scn.name;
const SCN=[
{id:'stg',n:tr('Only Spätzle-IX'),city:'stg',cash:400000,days:730,rules:{noTransit:true},d:tr('Start in Stuttgart, where nobody sells transit. Reach the internet through peering, PNIs, caches and your own fiber only. No transit anywhere, ever.'),goal:tr('Serve 200 Gbps'),ok:()=>R.served>=200},
{id:'redsea',n:tr('Red Sea Crisis'),city:'mrs',cash:2500000,days:540,rules:{banCities:['cai','jed'],banPairs:['eig:dxb-mrs','gbi:fuj-mrs','smw4:khi-mrs','smw6:mrs-bom','smw6:mrs-sin','peace:mrs-sin','aae:mrs-hkg','twoaf:mrs-bom','medn:cai-mrs','medn:ist-mrs','twoaf:jnb-mrs','eassy:nbo-mrs']},d:tr('Every cable through the Red Sea is cut, and so is the hop to Egypt. Get Marseille talking to Singapore anyway: round Africa, overland, or the other way round the planet.'),goal:tr('A path from Marseille to Singapore, and 300 Gbps served'),ok:()=>pathExists('mrs','sin')&&R.served>=300},
@ -1186,7 +1189,7 @@ function trPaths(src){const live=S.links.filter(l=>!linkDown(l)),rem=remoteCitie
const path=dst=>{if(dist[dst]===undefined)return null;const out=[];let v=dst;while(v!==src){const l=prev[v];out.unshift({l,from:l.a===v?l.b:l.a,to:v});v=l.a===v?l.b:l.a;}return out;};return {dist,path};}
function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[];
for(const x of S.caches)if(x.net===net&&popUp(x.city)&&!siteDown(x.city,'a'))out.push({k:'c',rank:0,city:x.city,pref:'normal',lab:tr('{name} cache',{name:NET[net].cache.name}),used:R.useCache[x.id]||0,cap:CACHE_CAP});
for(const p of S.pni)if(p.net===net&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:1,city:p.city,pref:p.pref||'normal',lab:tr('PNI with {name}',{name:NET[net].name}),used:R.usePni[p.id]||0,cap:liveCap(PORT[p.tier].g,p.city,p.site,p.n)});
for(const p of S.pni)if(p.net===net&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:1,city:p.city,pref:p.pref||'normal',lab:tr('PNI with {net}',{net:NET[net].name}),used:R.usePni[p.id]||0,cap:liveCap(PORT[p.tier].g,p.city,p.site,p.n)});
for(const c in S.ixp)if(ixSessions(c).has(net)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:2,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('{ix} peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',lab:tr('{name} transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
return out;}
@ -1236,7 +1239,7 @@ function shareCanvas(){const Wc=1200,Hc=630,cv=document.createElement('canvas');
// stats
const got=BADGES.filter(b=>S.ach&&S.ach[b.id]!==undefined),rk={l:0,e:1,r:2,c:3},top=got.slice().sort((a,b)=>rk[a.r]-rk[b.r]).slice(0,8);
const rows=[[tr('Peak traffic'),fmtG(S.stats.peak||0)],[tr('Peered'),pct(R.peerShare||0)],[tr('POPs'),tr('{n} in {r} regions',{n:Object.keys(S.pops).length,r:regionsCount()})],[tr('Links'),String(S.links.length)],[tr('Customers'),String(S.biz.length)],[tr('Incidents survived'),String(S.stats.survived||0)],[tr('Shark bites'),String(S.stats.sharks||0)],[tr('Badges'),`${got.length}/${BADGES.length}`]];
if(S.scn)rows.unshift([S.scn.id==='weekly'?tr('Weekly {key}',{key:S.scn.key}):S.scn.name,S.scn.done?(S.scn.id==='weekly'?tr('score {v}',{v:fmtG(S.scn.score||S.stats.peak||0)}):tr('done in {n} days',{n:S.scn.done})):S.scn.failed?tr('not this time'):tr('in progress')]);
if(S.scn)rows.unshift([scnName(),S.scn.done?(S.scn.id==='weekly'?tr('score {v}',{v:fmtG(S.scn.score||S.stats.peak||0)}):tr('done in {d} days',{d:S.scn.done})):S.scn.failed?tr('not this time'):tr('in progress')]);
let y=150;for(const [k,v] of rows.slice(0,9)){g.fillStyle='#fff';g.strokeStyle='#1E2640';g.lineWidth=3;g.beginPath();g.roundRect?g.roundRect(770,y,390,42,12):g.rect(770,y,390,42);g.fill();g.stroke();g.fillStyle='#5A6280';g.font='800 18px Nunito, sans-serif';g.fillText(k,786,y+11);g.fillStyle='#1E2640';g.font='900 22px Nunito, sans-serif';const tw=g.measureText(v).width;g.fillText(v,1146-tw,y+9);y+=48;}
g.font='34px sans-serif';top.forEach((b,i)=>g.fillText(b.i,40+i*48,520));
g.fillStyle='#1E2640';g.font='900 30px "Baloo 2", sans-serif';g.fillText('seriesoftub.es',40,572);g.font='700 20px Nunito, sans-serif';g.fillText(tr('Build the internet, one tube at a time'),300,580);
@ -1379,7 +1382,7 @@ function peerOk(id,via,city){
const HOT=0.9,HOTL={t:'T',ix:'IX',p:'P',c:'C',r:'R'},HOTC={t:'#7B61FF',ix:'#FFD23F',p:'#2C7A7B',c:'#C8102E',r:'#FF4F9A'};
function hotPorts(){const out=[];if(!R||!S)return out;
for(const t of S.transit){if(t.down>S.day)continue;const cap=lagCap(PORT[t.tier].g,t.n),u=(R.useT[t.id]||0)/cap;if(u>=HOT)out.push({k:'t',city:t.city,lab:tr('{net} transit · {lag}',{net:NET[t.net].name,lag:lagName(t.tier,t.n)}),u,tip:tr('Add a LAG member, upgrade the port or buy a second upstream.')});}
for(const c in S.ixp){const cap=ixCap(c);if(!cap)continue;const u=(R.useIx[c]||0)/cap;if(u>=HOT)out.push({k:'ix',city:ixCity(c),lab:tr('{ix} port',{ix:ixName(c)}),u,tip:tr('Upgrade the IX port or add a LAG member.')});}
for(const c in S.ixp){const cap=ixCap(c);if(!cap)continue;const u=(R.useIx[c]||0)/cap;if(u>=HOT)out.push({k:'ix',city:ixCity(c),lab:tr('{port} port',{port:ixName(c)}),u,tip:tr('Upgrade the IX port or add a LAG member.')});}
for(const p of S.pni){const cap=lagCap(PORT[p.tier].g,p.n),u=(R.usePni[p.id]||0)/cap;if(u>=HOT)out.push({k:'p',city:p.city,lab:tr('PNI with {net}',{net:NET[p.net].name}),u,tip:tr('Add a LAG member or upgrade the PNI.')});}
const cc={};for(const x of S.caches){const k=x.city+'|'+x.net;(cc[k]=cc[k]||{city:x.city,net:x.net,used:0,cap:0});cc[k].used+=R.useCache[x.id]||0;cc[k].cap+=CACHE_CAP;}
for(const k in cc){const x=cc[k],u=x.used/x.cap;if(u>=HOT)out.push({k:'c',city:x.city,lab:x.cap>CACHE_CAP?tr('{name} caches',{name:NET[x.net].cache.name}):tr('{name} cache',{name:NET[x.net].cache.name}),u,tip:tr('Ask for another box. The overflow goes out over peering or transit.')});}
@ -1754,8 +1757,8 @@ function portNote(c){const p=S.pops[c];if(!p)return '';const g=p.rgen||0;return
function sfOf(r,c){const d=r.cityDem[c]||0;return d<=1e-6?1:clamp(r.citySrv[c]/d,0,1);}
/* ---------- failures & events ---------- */
// A few badges read the incident text, which is in the player’s language, so the patterns match the Italian too.
function addInc(o){o.id=uid();o.start=S.day;S.inc.push(o);S.stats.incidents++;S.stats.by=S.stats.by||{};S.stats.by[o.type]=(S.stats.by[o.type]||0)+1;if(/shark|squal[oi]\b/i.test(o.msg||''))S.stats.sharks=(S.stats.sharks||0)+1;const f=S.stats.f=S.stats.f||{};if(/anchor|àncor/i.test(o.msg||''))f.anchor=1;if(/crocodile|coccodrill/i.test(o.msg||''))f.croc=1;if(/llama|\blama\b/i.test(o.msg||''))f.llama=1;}
// A few badges read the incident text: callers whose message mentions a shark, anchor, crocodile or llama pass its English as en.
function addInc(o,en=o.msg||''){o.id=uid();o.start=S.day;S.inc.push(o);S.stats.incidents++;S.stats.by=S.stats.by||{};S.stats.by[o.type]=(S.stats.by[o.type]||0)+1;if(/shark/i.test(en))S.stats.sharks=(S.stats.sharks||0)+1;const f=S.stats.f=S.stats.f||{};if(/anchor/i.test(en))f.anchor=1;if(/crocodile/i.test(en))f.croc=1;if(/llama/i.test(en))f.llama=1;}
const HARMLESS=[
[tr('Certificate expired'),tr('The TLS certificate on your NOC dashboard expired. Nobody can see any graphs, so technically there are no problems.')],
[tr('It was DNS'),tr('Someone deleted the DNS record for the internal wiki. The runbook for fixing DNS was on the wiki.')],
@ -1832,8 +1835,8 @@ function fireFailure(){
const mon=Math.floor((S.day%365)/30.42),monsoon=mon>=5&&mon<=8,tw=x=>x.sub&&(x.a==='tpe'||x.b==='tpe'||['clion','balt'].includes(x.cable)),vn=x=>x.sub&&(x.a==='sgn'||x.b==='sgn'),inl=x=>!x.sub&&(CITY[x.a].india||CITY[x.b].india);
const l=pick(live.flatMap(x=>{const w=(x.cable&&CAB[x.cable].age==='old'?3:1)*(tw(x)?4*(scnRule('anchors')?3:1):1)*(scnRule('sharks')&&x.sub?2:1)*(vn(x)?3:1)*(!x.sub&&andesPair(x.a,x.b)?4:1)*(monsoon&&inl(x)?3:1);return Array(w).fill(x);})),dur=10+Math.floor(Math.random()*8),trc=l.trench||l.id,hit=S.links.filter(x=>(x.trench||x.id)===trc);hit.forEach(x=>x.cut=Math.max(x.cut||0,S.day+dur));
const A=CITY[l.a].name,B=CITY[l.b].name;
const msg=vn(l)&&Math.random()<0.8?pick([tr('Another of Vietnam’s subsea cables is broken: your {a}–{b} link. The repair ship will come after the holidays. Which holidays is unclear.',{a:A,b:B}),tr('Your {a}–{b} cable broke in the same spot as last time. The repair crew recognised it.',{a:A,b:B})]):!l.sub&&(l.a==='drw'||l.b==='drw')&&Math.random()<0.7?pick([tr('A crocodile took a bite out of your {a}–{b} fiber. It was not impressed.',{a:A,b:B}),tr('Termites ate the duct on {a}–{b}. Then the fiber. Then the replacement duct.',{a:A,b:B})]):tw(l)&&Math.random()<0.8?pick([tr('A cargo ship “forgot” to raise its anchor and dragged it across your {a}–{b} cable. The owners are very sorry, and somewhat hard to reach.',{a:A,b:B}),tr('Another anchor, another cut: your {a}–{b} cable. The ship’s flag changed twice during the investigation.',{a:A,b:B}),tr('A fishing boat with an unusually heavy anchor cut {a}–{b}. It was not fishing.',{a:A,b:B})]):!l.sub&&andesPair(l.a,l.b)?pick([tr('A landslide in the Andes buried your {a}–{b} fiber.',{a:A,b:B}),tr('Snow closed the mountain pass, and the repair crew with it: {a}–{b} is down.',{a:A,b:B}),tr('An earthquake shook your {a}–{b} fiber loose somewhere above 4,000 metres.',{a:A,b:B}),tr('A llama herd trampled the fiber marker on {a}–{b}. Then a backhoe found the fiber.',{a:A,b:B})]):!l.sub&&(CITY[l.a].india||CITY[l.b].india)?pick([tr('Road widening near {a} cut your fiber to {b}. It is always road widening.',{a:A,b:B}),tr('The monsoon flooded a manhole on {a}–{b}. The fiber is now underwater, as is the manhole.',{a:A,b:B}),tr('A digger found your {a}–{b} fiber. A different digger is coming to fix it.',{a:A,b:B})]):l.sub?pick([tr('A curious shark bit your subsea cable {a}–{b}.',{a:A,b:B}),tr('A ship dragged its anchor across your {a}–{b} cable.',{a:A,b:B}),tr('An undersea landslide snapped {a}–{b}.',{a:A,b:B})]):pick([tr('A backhoe found your fiber between {a} and {b}.',{a:A,b:B}),tr('Squirrels chewed through {a}–{b}. They regret nothing.',{a:A,b:B}),tr('Road works cut {a}–{b}. Nobody called before digging.',{a:A,b:B})]);
addInc({type,ref:trc,until:S.day+dur,msg:msg+(hit.length>1?' '+tr('All {n} links in that trench went down with it.',{n:hit.length}):''),cost:Math.max(4000,Math.round(hit.reduce((a,x)=>a+x.mo,0)*0.5))});
const en=vn(l)&&Math.random()<0.8?pick([N_('Another of Vietnam’s subsea cables is broken: your {a}–{b} link. The repair ship will come after the holidays. Which holidays is unclear.'),N_('Your {a}–{b} cable broke in the same spot as last time. The repair crew recognised it.')]):!l.sub&&(l.a==='drw'||l.b==='drw')&&Math.random()<0.7?pick([N_('A crocodile took a bite out of your {a}–{b} fiber. It was not impressed.'),N_('Termites ate the duct on {a}–{b}. Then the fiber. Then the replacement duct.')]):tw(l)&&Math.random()<0.8?pick([N_('A cargo ship “forgot” to raise its anchor and dragged it across your {a}–{b} cable. The owners are very sorry, and somewhat hard to reach.'),N_('Another anchor, another cut: your {a}–{b} cable. The ship’s flag changed twice during the investigation.'),N_('A fishing boat with an unusually heavy anchor cut {a}–{b}. It was not fishing.')]):!l.sub&&andesPair(l.a,l.b)?pick([N_('A landslide in the Andes buried your {a}–{b} fiber.'),N_('Snow closed the mountain pass, and the repair crew with it: {a}–{b} is down.'),N_('An earthquake shook your {a}–{b} fiber loose somewhere above 4,000 metres.'),N_('A llama herd trampled the fiber marker on {a}–{b}. Then a backhoe found the fiber.')]):!l.sub&&(CITY[l.a].india||CITY[l.b].india)?pick([N_('Road widening near {a} cut your fiber to {b}. It is always road widening.'),N_('The monsoon flooded a manhole on {a}–{b}. The fiber is now underwater, as is the manhole.'),N_('A digger found your {a}–{b} fiber. A different digger is coming to fix it.')]):l.sub?pick([N_('A curious shark bit your subsea cable {a}–{b}.'),N_('A ship dragged its anchor across your {a}–{b} cable.'),N_('An undersea landslide snapped {a}–{b}.')]):pick([N_('A backhoe found your fiber between {a} and {b}.'),N_('Squirrels chewed through {a}–{b}. They regret nothing.'),N_('Road works cut {a}–{b}. Nobody called before digging.')]);
addInc({type,ref:trc,until:S.day+dur,msg:tr(en,{a:A,b:B})+(hit.length>1?' '+tr('All {n} links in that trench went down with it.',{n:hit.length}):''),cost:Math.max(4000,Math.round(hit.reduce((a,x)=>a+x.mo,0)*0.5))},en);
}else if(type==='crash'||type==='power'){
const c=pick(Object.keys(S.pops).flatMap(x=>type==='power'&&(CITY[x].za||CITY[x].blackout)?[x,x,x]:type==='crash'&&RG[S.pops[x].rgen||0].flaky?[x,x,x]:[x])),pp=S.pops[c],slow=slowBoot(c),dur=(type==='crash'?2+Math.floor(Math.random()*2):3+Math.floor(Math.random()*3))*(type==='crash'&&S.ev.sanction>S.day?2:1)+(slow?2+Math.floor(Math.random()*3):0);
if(type==='crash'&&(pp.routers||1)>=2){pp.rdown=S.day+dur;S.stats.incidents++;S.stats.survived++;toast(tr('<b>Router crash in {city}</b><br>One router panicked and its twin took over.{slow} Capacity there is down one router for {d} days.',{city:CITY[c].name,slow:slow?' '+tr('The crashed one {what}.',{what:esc(pick(SLOW_BOOT))}):'',d:dur}),'good');sfx('alert');return;}
@ -1913,11 +1916,11 @@ function fireEvent(){
if(e==='runet'){S.ev.runet=S.day+1;toast(tr('<b>Sovereign internet drill</b><br>Moscow unplugged itself from the rest of the internet for a day to see what happens. Everything leaving Russia is dark until tomorrow.'),'bad');sfx('alert');compute();return;}
if(e==='baltic'){const BAL=['clion','havf','danice'];const hit=S.links.filter(l=>l.cable&&BAL.includes(l.cable)&&!(l.cut>S.day));
if(!hit.length){toast(tr('<b>Baltic cable damaged</b><br>A cargo ship dragged its anchor for 100 km and swears it noticed nothing. You have no links on those cables.'),'goal');return;}
const dur=15+Math.floor(Math.random()*15);for(const tk of new Set(hit.map(l=>l.trench||l.id))){S.links.filter(l=>(l.trench||l.id)===tk).forEach(l=>l.cut=Math.max(l.cut||0,S.day+dur));addInc({type:'redsea',ref:tk,until:S.day+dur,msg:tr('A cargo ship dragged its anchor along the Baltic seabed for 100 km and swears it noticed nothing. Investigators are “looking into it”.'),cost:0});}
const dur=15+Math.floor(Math.random()*15),en=N_('A cargo ship dragged its anchor along the Baltic seabed for 100 km and swears it noticed nothing. Investigators are “looking into it”.');for(const tk of new Set(hit.map(l=>l.trench||l.id))){S.links.filter(l=>(l.trench||l.id)===tk).forEach(l=>l.cut=Math.max(l.cut||0,S.day+dur));addInc({type:'redsea',ref:tk,until:S.day+dur,msg:tr(en),cost:0},en);}
toast(tr('<b>Baltic cable damaged</b><br>{n} of your links are down for about {d} days.',{n:hit.length,d:dur}),'bad');sfx('alert');compute();return;}
if(e==='redsea'){const RED=['twoaf','smw6','peace','aae','eig','eassy'];const hit=S.links.filter(l=>l.cable&&RED.includes(l.cable)&&!(l.cut>S.day));
if(!hit.length){toast(tr('<b>Cables cut in the Red Sea</b><br>A ship dragged its anchor across several cables. Everyone blames everyone. Luckily you do not use those cables.'),'goal');return;}
const dur=20+Math.floor(Math.random()*15);for(const tk of new Set(hit.map(l=>l.trench||l.id))){S.links.filter(l=>(l.trench||l.id)===tk).forEach(l=>l.cut=Math.max(l.cut||0,S.day+dur));addInc({type:'redsea',ref:tk,until:S.day+dur,msg:tr(`A ship drifting without power dragged its anchor through the Red Sea cables. Everyone blames everyone. Repair ships need permits from three governments.`),cost:0});}
const dur=20+Math.floor(Math.random()*15),en=N_(`A ship drifting without power dragged its anchor through the Red Sea cables. Everyone blames everyone. Repair ships need permits from three governments.`);for(const tk of new Set(hit.map(l=>l.trench||l.id))){S.links.filter(l=>(l.trench||l.id)===tk).forEach(l=>l.cut=Math.max(l.cut||0,S.day+dur));addInc({type:'redsea',ref:tk,until:S.day+dur,msg:tr(en),cost:0},en);}
toast(tr('<b>Cables cut in the Red Sea</b><br>{n} of your subsea links are down for about {d} days while the diplomats argue about repair ships.',{n:hit.length,d:dur}),'bad');sfx('alert');compute();return;}
if(e==='golden'){S.ev.golden=S.day+7;toast(tr('<b>Golden Week!</b><br>Demand in mainland China is up 40% for a week.'),'goal');return;}
if(e==='gfw'){S.ev.gfw=S.day+10;toast(tr('<b>The border got stricter.</b><br>Cross-border packet loss rises to 35% for 10 days. Premium routes are barely affected.'),'bad');sfx('alert');return;}
@ -2344,7 +2347,7 @@ function renderHUD(){
for(const v of [0,0.5,1,2,4,8]){const b=$('sp'+v);if(b)b.classList.toggle('on',UI.speed===v);}
$('muteBtn').style.opacity=UI.muted?.4:1;
if(!S)return;
$('hName').textContent=S.name;$('hAsn').textContent='AS'+S.asn+(S.mode==='sandbox'?' · '+tr('Sandbox'):S.scn?' · '+(S.scn.id==='weekly'?tr('Weekly {key}',{key:S.scn.key}):S.scn.name)+(S.scn.done||S.scn.failed?'':` · ${tr('{n}d left',{n:Math.max(0,S.scn.days-S.day)})}`):'');
$('hName').textContent=S.name;$('hAsn').textContent='AS'+S.asn+(S.mode==='sandbox'?' · '+tr('Sandbox'):S.scn?' · '+(scnName())+(S.scn.done||S.scn.failed?'':` · ${tr('{n}d left',{n:Math.max(0,S.scn.days-S.day)})}`):'');
$('hCash').textContent=fmt$(S.cash);$('hCash').style.color=S.cash<0?'var(--bad)':'';
const net=R.revMo-R.costMo;$('hRate').innerHTML=`<span class="${net>=0?'up':'down'}">${net>=0?'▲':'▼'} ${tr('{price}/mo',{price:fmt$(Math.abs(net))})}</span>`;
$('hTraffic').textContent=`${fmtG(R.served)}`;
@ -2487,7 +2490,7 @@ function cityPanel(c){
${UI.models?routerModels(c):''}
${N||UI.models?`<p class="note">${rt>1?tr('Rolling upgrade: one router at a time, no downtime.'):tr('With one router, the upgrade needs a maintenance window: this POP goes dark for a day.')}</p>`:''}
<p class="note">${rt>=2?tr('A crash here only costs one router’s capacity for a few days.'):tr('One router is a single point of failure.')}</p></section>
<section><h3>${tr('Metro diversity')}</h3>${p.site2?(()=>{const up=s=>[...S.transit.filter(t=>t.city===c&&onSite(t.site,s)).map(t=>tr('{net} transit',{net:NET[t.net].name})+(t.site==='ab'?' '+tr('(split)'):'')),...S.pni.filter(x=>x.city===c&&onSite(x.site,s)).map(x=>'PNI '+NET[x.net].name+(x.site==='ab'?' '+tr('(split)'):'')),...ixIdsIn(c).filter(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&onSite((S.ixSite||{})[x],s)).map(x=>tr('{ix} port',{ix:ixName(x)})+((S.ixSite||{})[x]==='ab'?' '+tr('(split)'):'')),...(s==='a'?S.caches.filter(x=>x.city===c).map(x=>NET[x.net].cache.name):[])];
<section><h3>${tr('Metro diversity')}</h3>${p.site2?(()=>{const up=s=>[...S.transit.filter(t=>t.city===c&&onSite(t.site,s)).map(t=>tr('{net} transit',{net:NET[t.net].name})+(t.site==='ab'?' '+tr('(split)'):'')),...S.pni.filter(x=>x.city===c&&onSite(x.site,s)).map(x=>'PNI '+NET[x.net].name+(x.site==='ab'?' '+tr('(split)'):'')),...ixIdsIn(c).filter(x=>S.ixp[x]!==undefined&&!S.myIx[x]&&onSite((S.ixSite||{})[x],s)).map(x=>tr('{port} port',{port:ixName(x)})+((S.ixSite||{})[x]==='ab'?' '+tr('(split)'):'')),...(s==='a'?S.caches.filter(x=>x.city===c).map(x=>NET[x.net].cache.name):[])];
const row=s=>{const dn=siteDown(c,s),u=up(s);return `<div class="row"><span class="logo" style="--c:${s==='a'?'#FF4F9A':'#7B61FF'}">${s.toUpperCase()}</span><div class="grow"><div class="nm">${esc(siteName(c,s))}${dn?' <span class="tag restrictive">DOWN</span>':''}</div><div class="meta">${u.length?esc(u.join(', ')):tr('Nothing plugged in here yet')}</div></div></div>`;};
return `<p class="lead">${tr('Two buildings joined by your own metro ring. A power cut or cleaner in one leaves the other running at half capacity. Uplinks only work while their site is up, unless you split them: choose <b>Both</b> on a port to put LAG members in each building.')}</p>${row('a')}${row('b')}${up('b').length&&up('a').length?'':`<p class="why">${tr('Everything is in one building. Move some uplinks to the other site from the Transit and Peering tabs.')}</p>`}<div class="kv"><span>${tr('Second site and metro ring')}</span><b>${tr('{price}/mo',{price:fmt$(SITE2_MO)})}</b></div><div class="btns">${btn(UI.confirm==='site'+c?tr('Really close it?'):tr('Close site B'),'rmSite',{city:c},'ghost sm')}</div>`;})()
:`<p class="lead">${tr('Right now {city} is one building. A power cut, an A/C failure or a cleaner with a vacuum takes the whole city dark, and a second router does not help with that. A second data center across town, joined by your own metro ring, keeps half the POP up.',{city:esc(CITY[c].name)})}</p><div class="btns">${btn(tr('Add a second site <small>{cost} + {mo}/mo</small>',{cost:fmt$(SITE2_COST),mo:fmt$(SITE2_MO)}),'addSite',{city:c},'pink',S.cash<SITE2_COST)}</div>`}</section>
@ -2497,7 +2500,7 @@ function cityPanel(c){
if(fabs.length){h+=`<section><h3>${tr('Interconnection fabrics (NNI)')}</h3><p class="lead">${tr('Buy a port on a fabric, then order virtual circuits to your other POPs or to a remote IX. Fast and flexible, but you share their fabric.')}</p>`;
for(const f of fabs){const pt=nniPort(c,f.id),used=nniUsed(c,f.id);
h+=`<div class="row"><span class="logo" style="--c:${f.col}">${initials(f)}</span><div class="grow"><div class="nm">${esc(f.name)}</div><div class="meta">${esc(f.blurb)}</div>`;
if(pt){const cap=NNI[pt.tier].g;h+=`<div class="kv"><span>${tr('{port} port · {price}/mo',{port:NNI[pt.tier].n,price:fmt$(NNI[pt.tier].mo)})}</span><b>${tr('{g} of circuits',{g:fmtG(used)})}</b></div><div class="bar ${barCls(used/cap)}"><i style="width:${used/cap*100}%"></i></div><div class="btns">${btn(tr('New circuit'),'openVxc',{from:c,prov:f.id},'pink sm')}${pt.tier<1?btn(tr('Upgrade 100G <small>{price}/mo</small>',{price:fmt$(NNI[1].mo)}),'buyNni',{city:c,prov:f.id,tier:1},'sm'):''}${btn(tr('Remove port'),'rmNni',{city:c,prov:f.id},'ghost sm')}</div>`;}
if(pt){const cap=NNI[pt.tier].g;h+=`<div class="kv"><span>${tr('{port} port · {price}/mo',{port:NNI[pt.tier].n,price:fmt$(NNI[pt.tier].mo)})}</span><b>${tr('{g} of circuits',{g:fmtG(used)})}</b></div><div class="bar ${barCls(used/cap)}"><i style="width:${used/cap*100}%"></i></div><div class="btns">${btn(tr('New circuit'),'openVxc',{from:c,prov:f.id},'pink sm')}${pt.tier<1?btn(tr('Upgrade {port} <small>{price}/mo</small>',{port:NNI[1].n,price:fmt$(NNI[1].mo)}),'buyNni',{city:c,prov:f.id,tier:1},'sm'):''}${btn(tr('Remove port'),'rmNni',{city:c,prov:f.id},'ghost sm')}</div>`;}
else h+=`<div class="btns">${NNI.map((N,i)=>btn(tr('{port} port <small>{price}/mo</small>',{port:N.n,price:fmt$(N.mo)}),'buyNni',{city:c,prov:f.id,tier:i},'sm',S.cash<N.mo)).join('')}</div>`;
h+=`</div></div>`;}
h+=`</section>`;}
@ -2725,7 +2728,7 @@ function showTitle(){
<label class="f" for="nmIn">${tr('Name your network')}</label><div class="network-name"><input class="t" id="nmIn" maxlength="24" value="${esc(UI.nm)}" autocomplete="off">${btn('Another one','randomName',{},'ghost sm')}</div>
<label class="f">${tr('Pick your home city')}</label><div class="starts">${starts.map(([c,d])=>`<button class="start ${UI.startCity===c?'on':''}" data-city="${c}" data-act="pickStart" data-args='{"city":"${c}"}'><b>${CITY[c].name}</b><span>${d}</span></button>`).join('')}</div>
<label class="f">${tr('Mode')}</label><div class="btns">${[['normal',tr('Normal')],['sandbox',tr('Sandbox')]].map(([m,l])=>`<button class="b sm modeb ${(UI.mode||'normal')===m?'pink':'ghost'}" data-m="${m}" data-act="modeSet" data-args='{"m":"${m}"}'>${l}</button>`).join('')}${btn(tr('Scenarios &amp; weekly challenge →'),'scenarios',{},'sm')}</div>
<label class="f">${tr('Language')}</label><div class="btns">${Object.entries(LANGS).map(([v,l])=>btn(l,'langSet',{v},LANG===v?'pink sm':'ghost sm')).join('')}</div>
<label class="f">${tr('Language')}</label><div class="btns">${segBtns('langSet',LANG,Object.entries(LANGS))}</div>
<div class="btns" style="margin-top:16px;justify-content:space-between;align-items:center">${btn(sv?tr('Start a new network'):tr('Start building'),'start',{},'big')}${btn(tr('How to play'),'help',{},'ghost')}${btn(tr('Import a save'),'importPick',{},'ghost sm')}</div><p class="ver">v${APP_VERSION} · <a href="https://github.com/fjaeckel/seriesoftubes" target="_blank" rel="noopener">${tr('Source on GitHub')}</a> · ${tr('Cookieless stats, no tracking')}</p>`);
$('nmIn').addEventListener('input',e=>{UI.nm=e.target.value;});
if(sv){S=migrate(sv);compute();}
@ -2839,11 +2842,13 @@ while(HILLS.length<130){const x=R1()*W,y=R1()*H;if(LANDS.some(l=>inPoly(x,y,l.pt
const CLOUDS=Array.from({length:7},(_,i)=>({x:R1()*W,y:60+R1()*(H-120),s:.7+R1()*.6,v:3+R1()*4}));
const FLOATS=[];
function floater(x,y,text,col){if(!animOn())return;FLOATS.push({x,y,text,col,t:performance.now()});}
/* Animation setting: auto follows the system's reduced-motion preference, or force it on or off. */
// Static markup: data-i18n text and every aria-label/title go through the dictionary once at boot.
function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.textContent);
for(const el of document.querySelectorAll('[aria-label],[title]'))for(const a of ['aria-label','title'])if(el.hasAttribute(a))el.setAttribute(a,tr(el.getAttribute(a)));}
function settingsRow(){const seg=(lab,act,cur,opts)=>`<div class="setline"><span>${lab}</span><div class="seg">${opts.map(([v,l])=>btn(l,act,{v},cur===v?'pink sm':'ghost sm')).join('')}</div></div>`;
for(const a of ['aria-label','title'])for(const el of document.querySelectorAll('['+a+']'))el.setAttribute(a,tr(el.getAttribute(a)));}
// One button per [value,label] option; the current one is highlighted.
function segBtns(act,cur,opts){return opts.map(([v,l])=>btn(l,act,{v},cur===v?'pink sm':'ghost sm')).join('');}
/* Animation setting: auto follows the system's reduced-motion preference, or force it on or off. */
function settingsRow(){const seg=(lab,act,cur,opts)=>`<div class="setline"><span>${lab}</span><div class="seg">${segBtns(act,cur,opts)}</div></div>`;
return `<div class="setrow"><h3 style="font-size:15px;margin:12px 0 4px">${tr('Settings')}</h3>${seg(tr('Animations'),'animSet',UI.anim||'auto',[['auto',tr('Auto')],['on',tr('On')],['off',tr('Off')]])}${seg(tr('Sound'),'soundSet',UI.muted?'off':'on',[['on',tr('On')],['off',tr('Off')]])}${seg(tr('Language'),'langSet',LANG,Object.entries(LANGS))}<p class="meta" style="margin:2px 0 0">${tr('Auto follows your device’s reduce-motion setting. Off freezes the map: no moving packets, pulses or floating text.')}</p></div>`;}
function animOn(){const m=UI.anim||'auto';if(m==='on')return true;if(m==='off')return false;try{return !matchMedia('(prefers-reduced-motion: reduce)').matches;}catch(e){return true;}}
function applyAnim(){const r=document.documentElement;r.classList.toggle('no-anim',UI.anim==='off');r.classList.toggle('anim-force',UI.anim==='on');if(!animOn())FLOATS.length=0;}

View file

@ -39,11 +39,14 @@ function tour(ev) {
const patched = failSrc.replace(/^function fireFailure/, 'function')
.replace('let tot=opts.reduce', `if(!opts.some(o=>o[0]==='${kind}'))return;opts.splice(0,opts.length,['${kind}',1]);let tot=opts.reduce`)
.replace('type=pick(f);}', `type=f.includes('${t}')?'${t}':pick(f);}`);
assert.ok(patched.includes(`['${kind}',1]`) && patched.includes(`f.includes('${t}')`), 'fireFailure still has the hooks this tour forces');
step('failure ' + t, `window.__ff=${patched};S.links.forEach(l=>{l.cut=0;l.eqDown=0;l.chFail=null});S.transit.forEach(t=>t.down=0);for(const c in S.pops)S.pops[c].down=0;compute();__ff();dayTick();ACT.leftTab({t:'noc'})`);
}
const evSrc = ev('fireEvent.toString()');
for (const e of ['viral', 'price', 'grant', 'sanction', 'tariff', 'hijack', 'landban', 'shutdown', 'redsea', 'baltic', 'runet', 'typhoon', 'golden', 'gfw', 'gulf']) {
step('event ' + e, `window.__fe=${evSrc.replace(/^function fireEvent/, 'function').replace('const e=pick(opts);', `const e='${e}';`)};__fe();dayTick();ACT.leftTab({t:'deals'})`);
const patched = evSrc.replace(/^function fireEvent/, 'function').replace('const e=pick(opts);', `const e='${e}';`);
assert.ok(patched.includes(`const e='${e}';`), 'fireEvent still has the hook this tour forces');
step('event ' + e, `window.__fe=${patched};__fe();dayTick();ACT.leftTab({t:'deals'})`);
}
for (let d = 0; d < 60; d++) step('late day ' + d, 'dayTick()');
step('lose', 'showLose()');
@ -52,11 +55,15 @@ function tour(ev) {
test('the game starts in English unless the player or the browser asks for another language', () => {
assert.equal(load().ev('LANG'), 'en');
const it = load({ navigatorLanguage: 'it-IT' });
assert.equal(load({ navigatorLanguage: 'it-IT' }).ev('SOT_LANG'), 'it', 'an Italian browser asks for Italian');
const it = load({ lang: 'it' });
assert.equal(it.ev('LANG'), 'it');
assert.equal(it.ev('document.documentElement.lang'), 'it');
assert.equal(load({ navigatorLanguage: 'it-IT', storage: { 'sot-lang': 'en' } }).ev('LANG'), 'en', 'a saved choice wins');
assert.equal(load({ storage: { 'sot-lang': 'xx' } }).ev('LANG'), 'en', 'unknown languages fall back to English');
const offline = load({ storage: { 'sot-lang': 'it' } });
assert.equal(offline.ev('LANG'), 'en', 'no dictionary, no Italian');
assert.equal(offline.ev('document.documentElement.lang'), 'en');
});
test('missing translations fall back to the English text, with placeholders filled', () => {
@ -82,6 +89,15 @@ test('picking a language saves the choice and the game, then reloads', () => {
assert.equal(ev("localStorage.getItem('sot-lang')"), 'it');
});
test('a scenario started in English shows its Italian name after switching', () => {
const en = load();
en.ev("ACT.startScn({id:'stg'});save()");
const { ev } = load({ lang: 'it', storage: { 'sot-save-v1': en.ev("localStorage.getItem('sot-save-v1')") } });
const name = ev("SCN.find(x=>x.id==='stg').n");
assert.notEqual(name, en.ev("SCN.find(x=>x.id==='stg').n"));
assert.ok(ev("document.getElementById('hAsn').textContent").includes(name));
});
for (const lang of ['en', 'it']) {
test(`${lang}: every screen, failure and event renders without errors or unfilled placeholders`, () => {
const { ev, errors } = load(lang === 'en' ? {} : { lang });