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
|
|
@ -20,18 +20,18 @@ function leaseSwaps(){const by={};
|
|||
if(op&&op.n<=DF_SYS[sys].max)x.opts.push(swapOpt('iru',DF_SYS[sys].cost+ampCount(km)*AMP_COST+op.up,dfLeaseMo(km)+ampCount(km)*AMP_MO+op.mo,30,wmo));}
|
||||
// Dig on land, lay a cable between landing stations (even ones that share a landmass), or both.
|
||||
const whys=[];for(const cab of [false,true]){if(cab?!seaCab(a,b):sub)continue;
|
||||
const why=cab?ownCabWhy(a,b):!dfAllowed(a,b)?tr('Nobody lets you dig on this route. Borders and licences are in the way, so keep leasing.'):lvl()<3?tr('Digging your own fiber unlocks at customer level 3.'):'';
|
||||
const why=cab?ownCabWhy(a,b):!dfAllowed(a,b)?tr('lease_swaps.nobody_lets_you_dig_on_this'):lvl()<3?tr('lease_swaps.digging_your_own_fiber_unlocks_at'):'';
|
||||
if(why){whys.push(why);continue;}const km=cab?ownCabKm(a,b):kmBetween(a,b),op=swapOptics(km,cap,cab,'roadm');
|
||||
if(!op){whys.push(tr('No optic you can buy reaches {km} km yet.',{km:km.toLocaleString()}));continue;}
|
||||
if(!op){whys.push(tr('lease_swaps.no_optic_you_can_buy_reaches',{km:km.toLocaleString()}));continue;}
|
||||
x.opts.push(swapOpt(cab?'cab':'own',(cab?ownCabCost(km):dfBuildCost(km)+DF_SYS.roadm.cost+ampCount(km)*AMP_COST)+op.up,(cab?ownCabMo(km):Math.round(km*0.15)+ampCount(km)*AMP_MO)+op.mo,cab?ownCabDays(km):dfBuildDays(km),mo));}
|
||||
x.why=x.opts.some(o=>o.k!=='iru')?'':whys.join(' ');
|
||||
const sv=[...x.opts.map(o=>o.save),x.lit].filter(v=>v!==undefined);if(sv.length)x.best=Math.max(...sv);return x;})
|
||||
.sort((p,q)=>((p.best===undefined)-(q.best===undefined))||(q.best||0)-(p.best||0)||q.mo-p.mo);}
|
||||
function leaseTab(){const xs=leaseSwaps(),tot=xs.reduce((s,x)=>s+x.mo,0);
|
||||
const kind=l=>l.kind==='vxc'?tr('{cap} fabric circuit',{cap:capName(l)}):l.kind==='df'?tr('{cap} on a dark fiber IRU',{cap:capName(l)}):tr('{cap} wave',{cap:capName(l)});
|
||||
const line=(x,o)=>{const a={up:fmt$(o.up),mo:fmt$(o.omo),n:o.days};return `<div class="meta">${o.k==='iru'?tr('Lease dark fiber: {up} up front, {mo}/mo, ready in about {n} days.',a):o.k==='cab'?tr('Your own cable: {up} up front, {mo}/mo, about {n} days to build.',a):tr('Your own fiber: {up} up front, {mo}/mo, about {n} days to build.',a)} <b style="color:${o.save>0?'var(--eye)':'var(--bad)'}">${o.save>0?tr('Saves {price}/mo, pays for itself in about {n} months.',{price:fmt$(o.save),n:o.pay}):tr('Costs more than leasing at this size.')}</b></div>`;};
|
||||
const plan=(x,o)=>btn(o.k==='iru'?tr('Plan dark fiber'):o.k==='cab'?tr('Plan a cable'):tr('Plan your own fiber'),'leaseSwap',{a:x.a,b:x.b,src:o.k==='iru'?'lease':o.k==='cab'?'cable':'build'},o.save>0&&o.save===x.best?'pink sm':'ghost sm');
|
||||
return `<div class="panel2" style="margin-top:12px"><h3>${tr('Leased lines')}</h3><p class="note" style="margin-top:0">${tr('Every wave, fabric circuit and dark fiber IRU you rent between two of your POPs, next to what leased dark fiber or your own fiber would cost. Estimates include the line system, amplifiers and enough optics for today’s capacity. Build first, move the traffic, then cancel the lease.')}</p>
|
||||
${xs.length?`<div class="kv"><span>${tr('You pay for leases')}</span><b>${tr('{price}/mo',{price:fmt$(tot)})}</b></div>`+xs.map(x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x.a].name} ⇄ ${CITY[x.b].name} <span class="tag st">${x.sub?tr('subsea'):tr('land')}</span></div><div class="meta">${Object.entries(x.ls.reduce((m,l)=>(m[kind(l)]=(m[kind(l)]||0)+1,m),{})).map(([k,n])=>n>1?`${n} × ${k}`:k).join(', ')} · ${tr('{price}/mo',{price:fmt$(x.mo)})}</div>
|
||||
${x.fit&&x.fit.fits?`<div class="meta">${x.own?tr('You already own fiber here. Light {n} more channels for {up}, then cancel the lease to save {price}/mo.',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.best)}):tr('You already lease dark fiber here. Light {n} more channels for {up}, then cancel the waves to save {price}/mo.',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.lit)})}</div>`:x.fit?`<div class="meta">${x.fit.n?tr('Your fiber here has room for {free} more channels, and moving these leases needs {n}. Light another fiber pair or upgrade the line system first.',{free:Math.max(0,x.fit.free),n:x.fit.n}):tr('No optic you can buy works on your fiber here yet.')}</div>`:''}${x.opts.map(o=>line(x,o)).join('')}${!x.own&&x.why?`<div class="meta">${esc(x.why)}</div>`:''}
|
||||
<div class="btns">${x.own?btn(tr('Open your fiber'),'dashLink',{id:x.own.id},'pink sm'):''}${x.iru&&x.fit?btn(tr('Open your dark fiber'),'dashLink',{id:x.iru.id},x.lit!==undefined?'pink sm':'ghost sm'):''}${x.opts.map(o=>plan(x,o)).join('')}${btn(tr('Open lease'),'dashLink',{id:(x.ls.find(l=>l.kind!=='df')||x.ls[0]).id},'ghost sm')}</div></div></div>`).join(''):`<p class="empty">${tr('You do not lease any lines between your POPs.')}</p>`}</div>`;}
|
||||
const kind=l=>l.kind==='vxc'?tr('lease_swaps.cap_fabric_circuit',{cap:capName(l)}):l.kind==='df'?tr('lease_swaps.cap_on_a_dark_fiber_iru',{cap:capName(l)}):tr('lease_swaps.cap_wave',{cap:capName(l)});
|
||||
const line=(x,o)=>{const a={up:fmt$(o.up),mo:fmt$(o.omo),n:o.days};return `<div class="meta">${o.k==='iru'?tr('lease_swaps.lease_dark_fiber_up_up_front',a):o.k==='cab'?tr('lease_swaps.your_own_cable_up_up_front',a):tr('lease_swaps.your_own_fiber_up_up_front',a)} <b style="color:${o.save>0?'var(--eye)':'var(--bad)'}">${o.save>0?tr('lease_swaps.saves_price_mo_pays_for_itself',{price:fmt$(o.save),n:o.pay}):tr('lease_swaps.costs_more_than_leasing_at_this')}</b></div>`;};
|
||||
const plan=(x,o)=>btn(o.k==='iru'?tr('lease_swaps.plan_dark_fiber'):o.k==='cab'?tr('lease_swaps.plan_a_cable'):tr('lease_swaps.plan_your_own_fiber'),'leaseSwap',{a:x.a,b:x.b,src:o.k==='iru'?'lease':o.k==='cab'?'cable':'build'},o.save>0&&o.save===x.best?'pink sm':'ghost sm');
|
||||
return `<div class="panel2" style="margin-top:12px"><h3>${tr('common.leased_lines')}</h3><p class="note" style="margin-top:0">${tr('lease_swaps.every_wave_fabric_circuit_and_dark')}</p>
|
||||
${xs.length?`<div class="kv"><span>${tr('lease_swaps.you_pay_for_leases')}</span><b>${tr('common.price_mo',{price:fmt$(tot)})}</b></div>`+xs.map(x=>`<div class="row"><div class="grow"><div class="nm">${CITY[x.a].name} ⇄ ${CITY[x.b].name} <span class="tag st">${x.sub?tr('common.subsea'):tr('common.land')}</span></div><div class="meta">${Object.entries(x.ls.reduce((m,l)=>(m[kind(l)]=(m[kind(l)]||0)+1,m),{})).map(([k,n])=>n>1?`${n} × ${k}`:k).join(', ')} · ${tr('common.price_mo',{price:fmt$(x.mo)})}</div>
|
||||
${x.fit&&x.fit.fits?`<div class="meta">${x.own?tr('lease_swaps.you_already_own_fiber_here_light',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.best)}):tr('lease_swaps.you_already_lease_dark_fiber_here',{n:x.fit.n,up:fmt$(x.fit.up),price:fmt$(x.lit)})}</div>`:x.fit?`<div class="meta">${x.fit.n?tr('lease_swaps.your_fiber_here_has_room_for',{free:Math.max(0,x.fit.free),n:x.fit.n}):tr('lease_swaps.no_optic_you_can_buy_works')}</div>`:''}${x.opts.map(o=>line(x,o)).join('')}${!x.own&&x.why?`<div class="meta">${esc(x.why)}</div>`:''}
|
||||
<div class="btns">${x.own?btn(tr('lease_swaps.open_your_fiber'),'dashLink',{id:x.own.id},'pink sm'):''}${x.iru&&x.fit?btn(tr('lease_swaps.open_your_dark_fiber'),'dashLink',{id:x.iru.id},x.lit!==undefined?'pink sm':'ghost sm'):''}${x.opts.map(o=>plan(x,o)).join('')}${btn(tr('common.open_lease'),'dashLink',{id:(x.ls.find(l=>l.kind!=='df')||x.ls[0]).id},'ghost sm')}</div></div></div>`).join(''):`<p class="empty">${tr('lease_swaps.you_do_not_lease_any_lines')}</p>`}</div>`;}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue