diff --git a/server-up/templates/index.html b/server-up/templates/index.html index e79702d..fd2732c 100644 --- a/server-up/templates/index.html +++ b/server-up/templates/index.html @@ -3642,7 +3642,7 @@ function app() { }, async loadLangs() { try { const d = await fetch('/api/i18n').then(r=>r.json()); this.languages = d.languages || []; } catch(e) {} }, async loadLang(code) { try { const d = await fetch('/api/i18n/'+code).then(r=>r.json()); this.T = d.strings || {}; } catch(e) {} }, - setLang(c) { localStorage.setItem('lang', c); this.loadLang(c); }, + setLang(c) { localStorage.setItem('lang', c); this._tzLanden = {}; this.loadLang(c); }, async openLangEditor(code) { const ref = await this.rpc('/api/i18n/keys'); diff --git a/tests/js/menu.test.js b/tests/js/menu.test.js index e9d6b36..ab2943e 100644 --- a/tests/js/menu.test.js +++ b/tests/js/menu.test.js @@ -839,6 +839,28 @@ check('balk staat halverwege', c.job.progress.pct === 50); check('stad die zo begint eerst', c.tzLijst()[0].id === 'Europe/Lisbon'); c.tzKiezer.q = 'nederland'; check('zoeken op land in het Nederlands', c.tzLijst().some(z => z.id === 'Europe/Amsterdam')); + // Een taalwissel zonder herladen moet ook reeds opgezochte landen vertalen. + const bewaardeOpslag = global.localStorage; + const taalWaarden = new Map([['lang', 'nl']]); + global.localStorage = {getItem: k => taalWaarden.get(k) || null, + setItem: (k, v) => taalWaarden.set(k, v)}; + try { + const taalApp = app(); + taalApp.loadLang = async () => {}; + taalApp.tzData = echteZones; + taalApp.tzKiezer = {open:true, q:'nederland', dichtbij:[], huidig:'UTC'}; + check('tijdzonekiezer begint met Nederlands land', taalApp.tzLand('NL') === 'Nederland'); + taalApp.setLang('en'); + check('tijdzonekiezer vertaalt een eerder opgezocht land na taalwissel', + taalApp.tzLand('NL') === 'Netherlands'); + taalApp.tzKiezer.q = 'netherlands'; + check('zoeken op de nieuwe landnaam werkt na taalwissel', + taalApp.tzLijst().some(z => z.id === 'Europe/Amsterdam')); + taalApp.setLang('nl'); + check('terugwisselen vertaalt de landnaam opnieuw', taalApp.tzLand('NL') === 'Nederland'); + } finally { + global.localStorage = bewaardeOpslag; + } c.tzKiezer.q = 'utc'; check('UTC is te kiezen hoewel zone.tab hem niet kent', c.tzLijst().some(z => z.id === 'UTC')); c.tzKiezer.q = 'new york';