diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d5d7f23..cc8291b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,7 +49,7 @@ Many people work on the game at once. A few habits keep your pull request from c ### Your branch still edits `site/index.html`? -Until version 1.33 the whole game was one file, `site/index.html`. If your branch was started before +Until version 1.34 the whole game was one file, `site/index.html`. If your branch was started before the split, merge `main` and let a script move your changes into `src/`: ```bash diff --git a/docs/adr/0002-one-page-assembled-at-build.md b/docs/adr/0002-one-page-assembled-at-build.md index d553d06..653d701 100644 --- a/docs/adr/0002-one-page-assembled-at-build.md +++ b/docs/adr/0002-one-page-assembled-at-build.md @@ -5,7 +5,7 @@ ## Context -Until 1.33 the whole game was `site/index.html`: about 900 KB and 5,100 lines of HTML, CSS and JavaScript +Until 1.34 the whole game was `site/index.html`: about 900 KB and 5,100 lines of HTML, CSS and JavaScript in one file, edited by many contributors at once. Nearly every pull request touched that file, so pull requests conflicted with each other all the time, reviews meant scrolling a 900 KB file, and nobody could tell from a diff's file list what a change was about. diff --git a/docs/adr/0003-translations-by-label.md b/docs/adr/0003-translations-by-label.md index 5ffe5d7..19a2c32 100644 --- a/docs/adr/0003-translations-by-label.md +++ b/docs/adr/0003-translations-by-label.md @@ -5,7 +5,7 @@ ## Context -Until 1.33 the English text was the key: code said `tr('Delivery: 2 to 6 weeks')`, and every dictionary +Until 1.34 the English text was the key: code said `tr('Delivery: 2 to 6 weeks')`, and every dictionary repeated that English as its key, `"Delivery: 2 to 6 weeks":"Consegna: da 2 a 6 settimane"`. So each of the ~2,900 strings existed four times (code, it, pt, fr), and more with every language. Fixing a typo in English meant renaming the key in every dictionary in the same change, or every translation silently @@ -36,7 +36,7 @@ fell back to English. Long sentences as keys made dictionary diffs hard to read English label is used, every translation keeps its English's placeholders, HTML tags and plural forms, and every dictionary is sorted. - **Saves:** a few things in a save hold text to show later (the peering inbox log, sold-out reasons, - attack names). New saves hold labels. Saves from 1.33 and older hold the English text; `tr()` maps it + attack names). New saves hold labels. Saves from before labels (1.34 and older) hold the English text; `tr()` maps it back to its label the first time it sees one, so old saves still show the player's language. - **Translators** read `src/i18n/en.js` next to their file; both are sorted by the same labels, so the same line numbers line up. @@ -48,7 +48,7 @@ fell back to English. Long sentences as keys made dictionary diffs hard to read rejects a label that is not the first argument of `tr()`/`trn()`/`N_()`, since the build cannot see it. `src/`, `npm run dev` and the tests all use the readable labels; `tests/pages.test.js` plays the shipped page in English, Italian and French. -- **Performance:** measured against 1.33 on the big-network save, routing, a game day, panels, the +- **Performance:** measured against 1.34 on the big-network save, routing, a game day, panels, the dashboard and the map are all unchanged, and boot time too. The page is about 4% bigger after compression (321 → 335 KB): the English moved from the code into its own dictionary, with an id each. The translation files are about 40% smaller (it.js 143 → 85 KB), so Italian, Portuguese and French diff --git a/scripts/legacy/labels.js b/scripts/legacy/labels.js index cd5d04b..ab21096 100644 --- a/scripts/legacy/labels.js +++ b/scripts/legacy/labels.js @@ -1,4 +1,4 @@ -// Turns English-keyed translation calls into label-keyed ones, for code written before labels (1.33 and +// Turns English-keyed translation calls into label-keyed ones, for code written before labels (1.34 and // older): tr('Delivery: about a month') → tr('pnis.delivery_about_a_month'), trn('{n} POP','{n} POPs',n) // → trn('common.n_pop',n), and data-i18n markup → data-i18n="page.…". It is how src/ got its labels, and // transforms.js runs it on old branches so their work lines up with src/ (see port-branch.js). diff --git a/scripts/legacy/port-branch.js b/scripts/legacy/port-branch.js index 4b20479..923043c 100644 --- a/scripts/legacy/port-branch.js +++ b/scripts/legacy/port-branch.js @@ -12,7 +12,7 @@ // that made src/ (split-index-html.js + transforms.js), and each partial gets a three-way merge // (git merge-file) into the src/ file from main. Your dictionary changes (site/i18n/*.js) are applied // entry by entry onto main's sorted dictionaries, so appended lines never conflict. Text keyed by English -// (before 1.34) gets the labels src/ uses, and new text gets new labels in src/i18n/en.js (labels.js). +// (1.34 and older) gets the labels src/ uses, and new text gets new labels in src/i18n/en.js (labels.js). // // It also works the other way round, merging commits made on the old layout into a branch that has src/. // Options: --base REF (the pre-split commit the old-layout side started from; default: merge-base of HEAD diff --git a/scripts/legacy/split-index-html.js b/scripts/legacy/split-index-html.js index 4a47af3..bb542f8 100644 --- a/scripts/legacy/split-index-html.js +++ b/scripts/legacy/split-index-html.js @@ -8,7 +8,7 @@ // node scripts/legacy/split-index-html.js INDEX_HTML OUT_DIR writes OUT_DIR/index.html and partials // // The cut points are found by content, not line numbers, so the same rules split any version from around -// the split (1.33.x). Comments directly above a cut point travel with the code below them. +// the split (1.33.x–1.34.x). Comments directly above a cut point travel with the code below them. const fs = require('node:fs'); const path = require('node:path'); diff --git a/src/game/00-core/10-language.js b/src/game/00-core/10-language.js index 84f27fe..affe784 100644 --- a/src/game/00-core/10-language.js +++ b/src/game/00-core/10-language.js @@ -7,7 +7,7 @@ const LANGS=window.SOT_LANGS,LANG=window.I18N?.[window.SOT_LANG]?window.SOT_LANG:'en'; document.documentElement.lang=LANG; const EN=window.I18N.en,DICT=Object.assign(Object.create(null),EN,LANG!=='en'&&window.I18N[LANG]); -// Saves from 1.33 and older hold English text where newer ones hold a label: map it on first use. +// Saves from before labels (1.34 and older) hold English text where newer ones hold a label: map it on first use. let EN_TEXT=null; function trKey(k){const o=DICT[k];if(o!==undefined)return o; if(!EN_TEXT){EN_TEXT=new Map();for(const l in EN){const e=EN[l],t=DICT[l];if(typeof e==='string')EN_TEXT.set(e,t);else{EN_TEXT.set(e.one,t.one||e.one);EN_TEXT.set(e.other,t.other||e.other);}}}