feat: Spanish translation

This commit is contained in:
JMF-Alex 2026-10-27 16:31:58 +01:00
parent 97b195dd91
commit 288c78e9a0
8 changed files with 2917 additions and 6 deletions

View file

@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- Series of Tubes now speaks Spanish. The game follows your browser's language the first time, and you can switch to Spanish under Settings or on the title screen.
## [1.34.1] — 2026-10-27
- The game starts faster in Italian, Portuguese and French: their translations are about 40% smaller to download.

View file

@ -45,7 +45,7 @@ npm run dev # http://localhost:8080
Progress is saved in your browser's local storage.
The game speaks English, Italian, Portuguese and French. It follows your browser's language the first time
The game speaks English, Italian, Portuguese, French and Spanish. It follows your browser's language the first time
and remembers the one you pick under Settings or on the title screen.
## Development
@ -68,6 +68,7 @@ site/ static files, deployed as they are
i18n/it.js Italian translation (label → text), loaded only when the game runs in Italian
i18n/pt.js Portuguese (Brazil) translation, loaded only when the game runs in Portuguese
i18n/fr.js French translation, loaded only when the game runs in French
i18n/es.js Spanish translation, loaded only when the game runs in Spanish
images/og-image.png social preview (1200×630)
favicon.*, icon-* favicons, app icons, manifest
sw.js service worker (offline play)

View file

@ -56,7 +56,7 @@ Development runs on `npm run dev` (assembles on every request, reloads on save);
| Path | What it is |
| --- | --- |
| `src/i18n/en.js` | English: label → text, one entry per line, sorted; inlined into the page by `<!-- @include i18n -->` |
| `site/i18n/it.js`, `pt.js`, `fr.js` | Translations: label → text, the same layout; loaded only for that language |
| `site/i18n/it.js`, `pt.js`, `fr.js`, `es.js` | Translations: label → text, the same layout; loaded only for that language |
| `site/sw.js` | Service worker: network-first for pages, stale-while-revalidate for assets. Cache name is stamped with the version |
| `site/site.webmanifest`, icons, `404.html`, `CNAME`, `robots.txt`, `sitemap.xml`, `llms.txt` | PWA and GitHub Pages files, copied as they are |
| `scripts/lib/page.js` | Assembles the page from `src/` (also from a git ref with `--ref`, for performance baselines) |

2903
site/i18n/es.js Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,7 @@
The page always comes from the network when there is one, so a new release shows up on the
next visit; everything else is served from the cache and refreshed in the background. */
const CACHE = 'sot-__VERSION__';
const CORE = ['/', '/index.html', '/site.webmanifest', '/favicon.svg', '/icon-192.png', '/icon-512.png', '/apple-touch-icon.png', '/i18n/it.js?v=__VERSION__', '/i18n/pt.js?v=__VERSION__', '/i18n/fr.js?v=__VERSION__'];
const CORE = ['/', '/index.html', '/site.webmanifest', '/favicon.svg', '/icon-192.png', '/icon-512.png', '/apple-touch-icon.png', '/i18n/it.js?v=__VERSION__', '/i18n/pt.js?v=__VERSION__', '/i18n/fr.js?v=__VERSION__', '/i18n/es.js?v=__VERSION__'];
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(CORE)).then(() => self.skipWaiting()));

View file

@ -154,7 +154,7 @@
<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',pt:'Português',fr:'Français'};let l=null;try{l=localStorage.getItem('sot-lang');}catch(e){}
(function(){const langs=window.SOT_LANGS={en:'English',it:'Italiano',pt:'Português',fr:'Français',es:'Español'};let l=null;try{l=localStorage.getItem('sot-lang');}catch(e){}
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>

View file

@ -62,6 +62,7 @@ test('the game starts in English unless the player or the browser asks for anoth
assert.equal(load({ navigatorLanguage: 'it-IT' }).ev('SOT_LANG'), 'it', 'an Italian browser asks for Italian');
assert.equal(load({ navigatorLanguage: 'pt-BR' }).ev('SOT_LANG'), 'pt', 'a Brazilian browser asks for Portuguese');
assert.equal(load({ navigatorLanguage: 'fr-FR' }).ev('SOT_LANG'), 'fr', 'a French browser asks for French');
assert.equal(load({ navigatorLanguage: 'es-ES' }).ev('SOT_LANG'), 'es', 'a Spanish browser asks for Spanish');
const it = load({ lang: 'it' });
assert.equal(it.ev('LANG'), 'it');
assert.equal(it.ev('document.documentElement.lang'), 'it');
@ -132,7 +133,7 @@ test('a scenario started in English shows its Italian name after switching', ()
assert.ok(ev("document.getElementById('hAsn').textContent").includes(name));
});
for (const lang of ['en', 'it', 'pt', 'fr']) {
for (const lang of ['en', 'it', 'pt', 'fr', 'es']) {
test(`${lang}: every screen, failure and event renders without errors or unfilled placeholders`, () => {
const { ev, errors } = load(lang === 'en' ? {} : { lang });
seed(ev, 3);
@ -145,6 +146,10 @@ for (const lang of ['en', 'it', 'pt', 'fr']) {
// short enough to stay on one line in the phone's top bar (Caisse · Banque wrapped and cut off the monthly line)
assert.equal(ev("document.querySelector('#hud [data-act=bank] .lbl').textContent"), 'Cash · Banque');
}
if (lang === 'es') {
assert.match(ev("document.getElementById('modalCard').textContent"), /Cómo jugar/);
assert.equal(ev("document.querySelector('#hud [data-act=bank] .lbl').textContent"), 'Caja · Banco');
}
const { thrown, leaks } = tour(ev);
assert.ok(ev('(S.stats.f||{}).anchor'), 'Baltic and Red Sea anchors count for the badge in every language');
assert.deepEqual(thrown, []);

View file

@ -390,7 +390,7 @@ test('DKNOG in Copenhagen is on the conference calendar', () => {
});
test('the Signal group is linked from the title screen, the menu and How to play, in every language', () => {
for (const lang of ['en', 'it', 'pt', 'fr']) {
for (const lang of ['en', 'it', 'pt', 'fr', 'es']) {
const { ev, errors } = load(lang === 'en' ? {} : { lang });
const links = (setup) => ev(`(()=>{${setup};return [...document.querySelectorAll('#modal a[href^="https://signal.group/#"]')].map(a=>a.target+'|'+a.rel+'|'+a.textContent.trim()).join('\\n');})()`);
const title = links('showTitle()');