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
|
|
@ -15,17 +15,17 @@ function meetSpots(id){const near=popNear();if(SPOTK!==NEARK){SPOTK=NEARK;SPOTM=
|
|||
return SPOTM[id]=Object.values(m).sort((a,b)=>(!!S.pops[b.c]-!!S.pops[a.c])||(near[a.c]-near[b.c])||(a.c<b.c?-1:1));}
|
||||
function meetLine(n,max){const sp=meetSpots(n.id);if(!sp.length)return '';
|
||||
const lab=x=>[x.pni?'PNI':'',...x.ix.map(ixName)].filter(Boolean).join(' · ');
|
||||
return `<div class="meta" style="margin-top:4px"><b>${tr('Where to meet them')}</b></div><div class="btns">${sp.slice(0,max).map(x=>btn(`${esc(CITY[x.c].name)} <small>${esc(lab(x))}</small>`,'meetGo',{city:x.c},S.pops[x.c]?'sm':'ghost sm')).join('')}${sp.length>max?btn(tr('+{n} more',{n:sp.length-max}),'netFocus',{id:n.id},'ghost sm'):''}</div>`;}
|
||||
return `<div class="meta" style="margin-top:4px"><b>${tr('meet_a_network.where_to_meet_them')}</b></div><div class="btns">${sp.slice(0,max).map(x=>btn(`${esc(CITY[x.c].name)} <small>${esc(lab(x))}</small>`,'meetGo',{city:x.c},S.pops[x.c]?'sm':'ghost sm')).join('')}${sp.length>max?btn(tr('dashboard.n_more',{n:sp.length-max}),'netFocus',{id:n.id},'ghost sm'):''}</div>`;}
|
||||
// The nearest place to meet a network you have no POP for, for one-line hints.
|
||||
function nearestSpot(id){const x=meetSpots(id)[0];return x&&!S.pops[x.c]?x:null;}
|
||||
// Networks you reach only through transit, biggest first: what stands between you and Tier 1.
|
||||
const ntLost=()=>NETS.filter(n=>!R.nt[n.id]).sort((a,b)=>NSH[b.id]-NSH[a.id]);
|
||||
function t1Card(){const cur=GOALS.find(g=>S.done[g.id]===undefined);if(!((cur&&cur.id==='t1')||S.won)||isTier1())return '';
|
||||
const need=t1Need(),miss=need.filter(n=>!S.pni.some(p=>p.net===n.id&&pniOn(p))),club=t1Club(),lost=ntLost(),nb=n=>btn(esc(n.name),'netFocus',{id:n.id},'ghost sm');
|
||||
let h=`<div class="pcard"><div class="eyebrow">${tr('Goal')} · ${tr('Go transit-free: Tier 1!')}</div><div class="pt">${tr('Road to Tier 1')}</div>`;
|
||||
h+=pRow({l:tr('Transit ports to cancel'),v:S.transit.length?0:1,max:1,txt:S.transit.length?String(S.transit.length):'✓'});
|
||||
h+=pRow({l:tr('PNIs with every Tier 1'),v:need.length-miss.length,max:need.length,txt:`${need.length-miss.length} / ${need.length}`});
|
||||
if(miss.length)h+=`<div class="btns">${miss.map(nb).join('')}</div>`+(club.ok?'':`<p class="why">${tr('Tier 1s only take a PNI from a network with {list}.',{list:club.missing.join(', ')})}</p>`);
|
||||
h+=pRow({l:tr('Reach without transit'),v:Math.min(R.reachNT,0.999),max:0.999,txt:`${reachPct(R.reachNT)} / 99.9%`});
|
||||
if(lost.length)h+=`<div class="btns">${lost.slice(0,3).map(nb).join('')}${btn(trn('All {n} out of reach','All {n} out of reach',lost.length),'netFilter',{f:'out'},'pink sm')}</div>`;
|
||||
let h=`<div class="pcard"><div class="eyebrow">${tr('common.goal')} · ${tr('common.go_transit_free_tier_1')}</div><div class="pt">${tr('meet_a_network.road_to_tier_1')}</div>`;
|
||||
h+=pRow({l:tr('meet_a_network.transit_ports_to_cancel'),v:S.transit.length?0:1,max:1,txt:S.transit.length?String(S.transit.length):'✓'});
|
||||
h+=pRow({l:tr('meet_a_network.pnis_with_every_tier_1'),v:need.length-miss.length,max:need.length,txt:`${need.length-miss.length} / ${need.length}`});
|
||||
if(miss.length)h+=`<div class="btns">${miss.map(nb).join('')}</div>`+(club.ok?'':`<p class="why">${tr('meet_a_network.tier_1s_only_take_a_pni',{list:club.missing.join(', ')})}</p>`);
|
||||
h+=pRow({l:tr('meet_a_network.reach_without_transit'),v:Math.min(R.reachNT,0.999),max:0.999,txt:`${reachPct(R.reachNT)} / 99.9%`});
|
||||
if(lost.length)h+=`<div class="btns">${lost.slice(0,3).map(nb).join('')}${btn(trn('meet_a_network.all_n_out_of_reach',lost.length),'netFilter',{f:'out'},'pink sm')}</div>`;
|
||||
return h+'</div>';}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue