Split the game page into partials under src/, assembled into one index.html at build
site/index.html (900 KB of HTML, CSS and JS in one file) becomes src/: a shell (src/index.html), styles/ and game/, concatenated in path order by scripts/lib/page.js. The assembled page is byte-identical to the old file, so load time and in-game performance are unchanged. - scripts/build.js replaces build.sh (same env vars, same output) - npm run dev: a zero-dependency dev server that assembles on every request - tests assemble the page in memory; npm test runs every tests/*.test.js - perf-bench takes --base-ref to build a git ref's page - scripts/legacy/split-index-html.js is the splitter, kept for older branches
This commit is contained in:
parent
295e68cc46
commit
67a40942b4
113 changed files with 5584 additions and 5195 deletions
11
src/game/00-core/10-language.js
Normal file
11
src/game/00-core/10-language.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/* ================= LANGUAGE =================
|
||||
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. */
|
||||
// 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});}
|
||||
function N_(s){return s;}
|
||||
Loading…
Add table
Add a link
Reference in a new issue