diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9563e13..f7c467c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
+- Language is now a dropdown on the title screen and in Settings, with each language named in itself. On phones it opens the system picker.
- Every new network starts at ½ speed, so you can find your feet before the bills arrive (#186). Saved games still continue at the speed you left them.
- You can put a link on standby, so one of two links between the same cities sits idle as a backup (#122). It carries traffic only when the other links are full or down, so its capacity is never wasted, and the map draws it dashed while it waits. The routing metric still applies to every link between the two cities.
diff --git a/src/game/95-modals/40-title.js b/src/game/95-modals/40-title.js
index c07dc78..8b0a732 100644
--- a/src/game/95-modals/40-title.js
+++ b/src/game/95-modals/40-title.js
@@ -9,7 +9,7 @@ function showTitle(){
`);
$('nmIn').addEventListener('input',e=>{UI.nm=e.target.value;});
if(sv){S=migrate(sv);compute();}
diff --git a/src/game/96-map/30-settings.js b/src/game/96-map/30-settings.js
index 5dd5c11..61aade4 100644
--- a/src/game/96-map/30-settings.js
+++ b/src/game/96-map/30-settings.js
@@ -3,6 +3,9 @@
function i18nDom(){if(LANG==='en')return;for(const el of document.querySelectorAll('[data-i18n]'))el.textContent=tr(el.dataset.i18n);
for(const a of ['aria-label','title'])for(const el of document.querySelectorAll(`[data-i18n-${a}]`))el.setAttribute(a,tr(el.getAttribute('data-i18n-'+a)));}
// One button per [value,label] option; the current one is highlighted.
+// One dropdown instead of a button per language: the list keeps growing, and on phones the system picker opens.
+// Each language is named in itself (lang= lets screen readers say it right).
+const langPick=id=>``;
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. */
/* Settings are per device (localStorage), not part of the save: they are about how you like to play. */
@@ -23,7 +26,7 @@ function settingsHtml(){const seg=(lab,act,cur,opts,note)=>`
`;}
const refreshSettings=()=>{if(UI.setOpen)openModal(settingsHtml());};
diff --git a/src/game/96-map/95-clicks.js b/src/game/96-map/95-clicks.js
index 7513a99..fdbce62 100644
--- a/src/game/96-map/95-clicks.js
+++ b/src/game/96-map/95-clicks.js
@@ -3,7 +3,7 @@ let pressing=false;
document.addEventListener('pointerdown',e=>{if(e.target.closest('#panel,#left,#dash,#bankBox,#modal,#tabbar,#toasts'))pressing=true;});
addEventListener('pointerup',()=>setTimeout(()=>pressing=false,0));
addEventListener('pointercancel',()=>{pressing=false;});addEventListener('blur',()=>{pressing=false;});
-document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||!S)return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});});
+document.addEventListener('change',e=>{const el=e.target.closest('[data-chg]');if(!el||(!S&&el.dataset.chg!=='langSet'))return;const fn=ACT[el.dataset.chg];if(fn)fn({v:el.value});});
/* Taps that land on the wrong thing (#44): a real tap only fires the button it went down on, never something that
appeared or moved under the finger, nothing behind a menu that opened or closed mid-tap, and no toast button in
the first half second after the toast popped up. Synthetic clicks (keyboard, tests) are not affected. */
diff --git a/src/styles/40-modal.css b/src/styles/40-modal.css
index 721724b..2eafe5b 100644
--- a/src/styles/40-modal.css
+++ b/src/styles/40-modal.css
@@ -26,7 +26,11 @@
@media (prefers-reduced-motion:reduce){:root:not(.anim-force) .coach-glow{animation:none;outline:3px solid #FF4F9A}}
:root.no-anim .coach-glow{outline:3px solid #FF4F9A}
.setline{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:4px 0}
-.setline>span{font-weight:800}
+.setline>span,.setline>label{font-weight:800}
+/* Dropdowns that look like the game's buttons. 16px text: iOS zooms into anything smaller when it is tapped. */
+select.pick{-webkit-appearance:none;appearance:none;font:800 16px var(--display);color:var(--ink);background:var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231E2640' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;border:3px solid var(--ink);border-radius:12px;padding:6px 36px 6px 12px;min-height:44px;cursor:pointer;box-shadow:0 3px 0 var(--ink)}
+select.pick:focus-visible{outline:3px solid #FF4F9A;outline-offset:2px}
+label.f+select.pick{width:100%}
.thb{font:inherit;font-weight:900;background:none;border:0;padding:0;cursor:pointer;color:inherit}
.ttop{margin:4px 0;padding:4px 8px;border-left:3px solid #FF8A3D;background:#FFF6EC;border-radius:6px}
.ibx{border:2px solid var(--line,#DDE3EE);border-radius:12px;padding:8px 10px;margin:8px 0;background:#fff}.ibx .nm{font-weight:800}.ibx.mp{border-color:#FF5A5F;background:#FFF1F1}.ibx.ai{border-color:#8E5CF7;background:#F7F2FF}.ibx .term{font-size:11.5px;white-space:pre-wrap;max-height:180px;overflow:auto}.ibx .cnt{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:var(--me);color:#fff;font-size:11px;text-align:center}.ibx .cnt.red{background:#FF5A5F}
diff --git a/tests/i18n.test.js b/tests/i18n.test.js
index 3de8051..9b38d9a 100644
--- a/tests/i18n.test.js
+++ b/tests/i18n.test.js
@@ -108,9 +108,10 @@ test('the static markup is translated by label', () => {
assert.equal(ev("document.querySelector('[data-act=help]').getAttribute('aria-label')"), ev("tr('common.how_to_play')"));
});
-test('the language buttons on the title screen work before any game exists', () => {
+test('the language dropdown on the title screen works before any game exists', () => {
const { ev } = load();
- ev("[...document.querySelectorAll('#modalCard [data-act=langSet]')].find(b=>b.textContent==='Italiano').click()");
+ assert.equal(ev('S'), null);
+ ev("const s=document.querySelector('#modalCard select#langTitle');s.value='it';s.dispatchEvent(new Event('change',{bubbles:true}))");
assert.equal(ev("localStorage.getItem('sot-lang')"), 'it');
});
diff --git a/tests/language-picker.test.js b/tests/language-picker.test.js
new file mode 100644
index 0000000..9bca04a
--- /dev/null
+++ b/tests/language-picker.test.js
@@ -0,0 +1,39 @@
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const { load } = require('./harness');
+
+const pick = (ev, id) => JSON.parse(ev(`(()=>{const s=document.getElementById('${id}');return JSON.stringify(s&&{tag:s.tagName,value:s.value,chg:s.dataset.chg,
+ opts:[...s.options].map(o=>[o.value,o.textContent,o.lang]),label:(document.querySelector('label[for=${id}]')||{}).textContent});})()`));
+
+test('language is one dropdown on the title screen and in Settings, in every language, with the current one selected', () => {
+ for (const lang of ['en', 'it', 'pt', 'fr', 'es']) {
+ const { ev, errors } = load(lang === 'en' ? {} : { lang });
+ const langs = JSON.parse(ev('JSON.stringify(Object.entries(LANGS))'));
+ const title = pick(ev, 'langTitle');
+ assert.equal(title.tag, 'SELECT', `${lang}: title screen`);
+ assert.equal(title.value, lang);
+ assert.deepEqual(title.opts, langs.map(([v, l]) => [v, l, v]), `${lang}: every language, named in itself`);
+ assert.equal(title.label, ev("tr('common.language')"), `${lang}: labelled`);
+ assert.equal(ev("document.querySelectorAll('#modalCard [data-act=langSet]').length"), 0, `${lang}: no language buttons left`);
+ ev("ACT.start({});ACT.settings()");
+ const set = pick(ev, 'langSel');
+ assert.equal(set.value, lang, `${lang}: settings`);
+ assert.equal(set.label, ev("tr('common.language')"));
+ assert.deepEqual(errors, []);
+ }
+});
+
+test('changing the dropdown in Settings switches language and keeps the game', () => {
+ const { ev, errors } = load();
+ ev("ACT.start({});dayTick();ACT.settings();const s=document.getElementById('langSel');s.value='fr';s.dispatchEvent(new Event('change',{bubbles:true}))");
+ assert.equal(ev("localStorage.getItem('sot-lang')"), 'fr');
+ assert.ok(ev("localStorage.getItem('sot-save-v1')"), 'saved before reloading');
+ assert.deepEqual(errors, []);
+});
+
+test('the dropdown fits a phone', () => {
+ const { ev, errors } = load();
+ ev('window.innerWidth=360;showTitle()');
+ assert.ok(ev("document.getElementById('langTitle').classList.contains('pick')"));
+ assert.deepEqual(errors, []);
+});