Translations keyed by labels instead of English text
tr('pnis.delivery_2_to_6_weeks') instead of tr('Delivery: 2 to 6 weeks'): the
English lives once, in src/i18n/en.js (inlined into the page at build, so no
extra request), and it/pt/fr map the same labels. Changing English wording no
longer renames a key in every dictionary.
- 2,899 labels, made from where each text is used and its first words; short
shared words are common.*
- plurals are one label with {one, other}: trn('label', n)
- static markup: data-i18n="label", data-i18n-aria-label, data-i18n-title
- saves from 1.33 and older stored English text in a few places; tr() still
resolves it
- i18n-check: undefined/unused labels, markup drift, plural shape; i18n-add.js
works on labels and --rename updates src/ too
- the old-branch port tool gives old English-keyed code and dictionaries the
same labels
This commit is contained in:
parent
d0ba85ef8f
commit
e817beed1a
94 changed files with 13681 additions and 10633 deletions
|
|
@ -1,23 +1,23 @@
|
|||
/* ================= INSTALL (PWA) ================= */
|
||||
let installEvt=null;
|
||||
addEventListener('beforeinstallprompt',e=>{e.preventDefault();installEvt=e;});
|
||||
addEventListener('appinstalled',()=>{installEvt=null;track('pwa_installed',true);if(UI.pendGame){const p=UI.pendGame;UI.pendGame=null;UI.pitched=true;beginGame(...p);}toast(tr('<b>Installed!</b><br>Open Series of Tubes from your home screen. Your saves come along.'),'good');});
|
||||
addEventListener('appinstalled',()=>{installEvt=null;track('pwa_installed',true);if(UI.pendGame){const p=UI.pendGame;UI.pendGame=null;UI.pitched=true;beginGame(...p);}toast(tr('install.installed_open_series_of_tubes_from'),'good');});
|
||||
const isStandalone=()=>{try{return navigator.standalone===true||!!(window.matchMedia&&matchMedia('(display-mode: standalone)').matches);}catch(e){return false;}};
|
||||
const isIOS=()=>/iPad|iPhone|iPod/.test(navigator.userAgent)||(navigator.platform==='MacIntel'&&navigator.maxTouchPoints>1);
|
||||
function installRow(){if(isStandalone())return '';
|
||||
return `<div class="row icard"><div class="grow"><div class="nm">📲 ${tr('Best played as an app')}</div><div class="meta">${tr('Full screen, works offline, one tap from your home screen.')}${isIOS()?' '+tr('Install it before you start: a game begun in Safari stays in Safari.'):''}</div></div>${btn(tr('Install'),'install',{},'pink sm')}</div>`;}
|
||||
return `<div class="row icard"><div class="grow"><div class="nm">📲 ${tr('install.best_played_as_an_app')}</div><div class="meta">${tr('install.full_screen_works_offline_one_tap')}${isIOS()?' '+tr('install.install_it_before_you_start_a'):''}</div></div>${btn(tr('common.install'),'install',{},'pink sm')}</div>`;}
|
||||
/* Phones get a real pitch before a new game: an installed app is full screen, works offline, and on iPhone
|
||||
keeps its save away from Safari's clean-ups. Storage is separate on iOS, so installing first matters. */
|
||||
const SHARE_SVG='<svg width="16" height="18" viewBox="0 0 16 18" aria-hidden="true"><path d="M8 1v10M4.5 4.5 8 1l3.5 3.5M5 7H2.5v9.5h11V7H11" fill="none" stroke="#1E2640" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
||||
const needPitch=()=>isPhone()&&!isStandalone();
|
||||
function installSteps(){
|
||||
if(isIOS())return `<ol class="isteps"><li>${tr('Tap <b>Share</b> {icon} in the browser toolbar.',{icon:SHARE_SVG})}</li><li>${tr('Tap <b>Add to Home Screen</b>. You may need to scroll down, or tap <b>More</b> first.')}</li><li>${tr('Open <b>Series of Tubes</b> from your home screen and start your network there.')}</li></ol>`;
|
||||
if(isIOS())return `<ol class="isteps"><li>${tr('install.tap_share_icon_in_the_browser',{icon:SHARE_SVG})}</li><li>${tr('install.tap_add_to_home_screen_you')}</li><li>${tr('install.open_series_of_tubes_from_your')}</li></ol>`;
|
||||
if(installEvt)return '';
|
||||
return `<ol class="isteps"><li>${tr('Open your browser menu (⋮).')}</li><li>${tr('Tap <b>Install app</b> or <b>Add to Home screen</b>.')}</li><li>${tr('Open <b>Series of Tubes</b> from your home screen.')}</li></ol>`;}
|
||||
return `<ol class="isteps"><li>${tr('install.open_your_browser_menu')}</li><li>${tr('install.tap_install_app_or_add_to')}</li><li>${tr('install.open_series_of_tubes_from_your_e03f')}</li></ol>`;}
|
||||
function pitchHtml(starting){const ios=isIOS();
|
||||
return `<div style="display:flex;align-items:center"><div>${starting?`<div class="eyebrow">${tr('Before you start')}</div>`:''}<h2 style="font-size:26px">📲 ${tr('Play it as an app')}</h2></div><button class="x" data-act="${starting?'pitchSkip':'closeModal'}" aria-label="${tr('Close')}">×</button></div>
|
||||
<p class="lead" style="margin-top:6px">${tr('Series of Tubes is made for your home screen. It takes ten seconds, costs nothing, and it is a much better game there:')}</p>
|
||||
<ul class="pitch"><li>🗺️ <b>${tr('Full screen.')}</b> ${tr('No browser bars, a lot more map.')}</li><li>📶 <b>${tr('Works offline.')}</b> ${tr('Build your backbone on the train or on a plane.')}</li>${ios?`<li>💾 <b>${tr('Your save stays safe.')}</b> ${tr('Safari can clear the data of websites you have not opened for a week. A home-screen app keeps its own.')}</li><li class="warn">⚠️ <b>${tr('Install first.')}</b> ${tr('On iPhone, a game started in Safari does not carry over to the home-screen app.')}</li>`:`<li>⚡ <b>${tr('One tap away.')}</b> ${tr('It opens straight into your network, like any other app.')}</li>`}</ul>
|
||||
return `<div style="display:flex;align-items:center"><div>${starting?`<div class="eyebrow">${tr('install.before_you_start')}</div>`:''}<h2 style="font-size:26px">📲 ${tr('install.play_it_as_an_app')}</h2></div><button class="x" data-act="${starting?'pitchSkip':'closeModal'}" aria-label="${tr('common.close')}">×</button></div>
|
||||
<p class="lead" style="margin-top:6px">${tr('install.series_of_tubes_is_made_for')}</p>
|
||||
<ul class="pitch"><li>🗺️ <b>${tr('common.full_screen')}</b> ${tr('install.no_browser_bars_a_lot_more')}</li><li>📶 <b>${tr('common.works_offline')}</b> ${tr('install.build_your_backbone_on_the_train')}</li>${ios?`<li>💾 <b>${tr('install.your_save_stays_safe')}</b> ${tr('install.safari_can_clear_the_data_of')}</li><li class="warn">⚠️ <b>${tr('common.install_first')}</b> ${tr('install.on_iphone_a_game_started_in')}</li>`:`<li>⚡ <b>${tr('install.one_tap_away')}</b> ${tr('install.it_opens_straight_into_your_network')}</li>`}</ul>
|
||||
${installSteps()}
|
||||
<div class="btns cta" style="margin-top:12px">${installEvt?btn(tr('Install the app'),'install',{},'pink big'):''}${starting?btn(tr('Play in the browser anyway'),'pitchSkip',{},installEvt?'ghost':'ghost big'):btn(tr('Got it'),'closeModal',{},installEvt?'ghost':'pink')}</div>`;}
|
||||
<div class="btns cta" style="margin-top:12px">${installEvt?btn(tr('install.install_the_app'),'install',{},'pink big'):''}${starting?btn(tr('install.play_in_the_browser_anyway'),'pitchSkip',{},installEvt?'ghost':'ghost big'):btn(tr('common.got_it'),'closeModal',{},installEvt?'ghost':'pink')}</div>`;}
|
||||
if('serviceWorker' in navigator&&location.protocol==='https:'&&!IS_DEV)addEventListener('load',()=>{navigator.serviceWorker.register('/sw.js').catch(()=>{});});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue