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:
Frederic Jung 2026-10-27 11:05:09 +01:00
parent d0ba85ef8f
commit e817beed1a
No known key found for this signature in database
94 changed files with 13681 additions and 10633 deletions

View file

@ -1,8 +1,8 @@
/* Big networks sometimes refuse to peer in a particular city, for a while. Each (network, city)
pair gets a stable verdict per window, derived from a hash, so asking again does not reroll it. */
const SNUB_WIN=150,SNUB_P=0.22;
const SNUB_IX=[tr('Only peers over PNIs in this metro. Order a cross-connect instead.'),tr('Their IX port here is full until the next upgrade. They promise it is soon.'),tr('Moved everything in this city to PNIs. Please read their PearingDB page, all 40 pages of it.'),tr('The peering coordinator for this city is on a six-month sabbatical.'),tr('Their policy here says "IX peering by invitation only". You were not invited.')];
const SNUB_ALL=[tr('Not accepting new peers in this region right now.'),tr('Region frozen while they renegotiate with the local incumbent.'),tr('Their routers in this city are "at capacity". They are not.'),tr('Already reach you through your transit provider here and think that is fine.'),tr('Their lawyers are reviewing every peering agreement in this country. Again.'),tr('A new VP wants to "monetise interconnection" in this market.')];
const SNUB_IX=[tr('peering_policy.only_peers_over_pnis_in_this'),tr('peering_policy.their_ix_port_here_is_full'),tr('peering_policy.moved_everything_in_this_city_to'),tr('peering_policy.the_peering_coordinator_for_this'),tr('peering_policy.their_policy_here_says_ix_peering')];
const SNUB_ALL=[tr('peering_policy.not_accepting_new_peers_in_this'),tr('peering_policy.region_frozen_while_they_renegotiate'),tr('peering_policy.their_routers_in_this_city_are'),tr('peering_policy.already_reach_you_through_your'),tr('peering_policy.their_lawyers_are_reviewing_every'),tr('peering_policy.a_new_vp_wants_to_monetise')];
function hstr(t){let h=2166136261;for(let i=0;i<t.length;i++){h^=t.charCodeAt(i);h=Math.imul(h,16777619);}return h>>>0;}
function bigPeer(n){return !!n&&n.pol==='selective'&&n.share>=0.03;}
function snub(id,c){
@ -15,8 +15,8 @@ function snub(id,c){
/* Remote peering: offered, but discouraged. A reseller marks up the port, oversubscribes it,
and many selective networks refuse members who are not physically in the building. */
const REMOTE_FEE=1.5,REMOTE_CAP=0.8;
const REMOTE_WARN=`<p class="note" style="color:var(--bad)">${tr('<b>Remote peering is a last resort.</b> Ports come through a reseller at 1.5× the price, only 80% of the port is really yours, latency rides the fabric, one fabric outage drops every session, and many selective networks refuse remote members. A POP here is better.')}</p>`;
const REMOTE_WHY=[tr('Policy: no remote peers. Be in the building or be in the transit bill.'),tr('Saw your session come in over a fabric and said "we can smell the VXC from here".'),tr('Only peers with members they can reach without a 1,500 km hairpin.'),tr('Their PearingDB entry says "Remote peering: No (we mean it)".'),tr('Tried a remote peer once. It flapped during a product launch. Never again.')];
const REMOTE_WARN=`<p class="note" style="color:var(--bad)">${tr('peering_policy.remote_peering_is_a_last_resort')}</p>`;
const REMOTE_WHY=[tr('peering_policy.policy_no_remote_peers_be_in'),tr('peering_policy.saw_your_session_come_in_over'),tr('peering_policy.only_peers_with_members_they_can'),tr('peering_policy.their_pearingdb_entry_says_remote'),tr('peering_policy.tried_a_remote_peer_once_it')];
function isRemote(c){return S.ixp[c]!==undefined&&!S.pops[ixCity(c)]&&!S.myIx[c];}
function noRemote(id){const n=NET[id];if(!n||n.pol!=='selective')return false;return hstr(id+'|remote')%100<(n.share>=0.03?60:30);}
/* Europe's peering market is crowded and competitive: ports are cheaper, and incumbents cut prices
@ -27,6 +27,6 @@ function ixPortMo(c,tier){const X=XIXM[c];if(X&&tier<=(X.freeTo??-1))return 0;re
function ixPriceWar(d){if(!S.ixp||Math.random()>=1/120)return;
const mine=Object.keys(S.ixp).filter(x=>{const c=ixCity(x);return CITY[c].reg==='EU'&&ixStatic(c).length>1;});if(!mine.length)return;
const x=pick(mine),c=ixCity(x),rival=pick(ixStatic(c).filter(y=>y!==x));
if(isDk(x)){toast(tr('<b>{rival} is poaching DE-KICKS members in {city}.</b><br>DE-KICKS responded with a webinar about "the value of premium interconnection". Prices unchanged.',{rival:esc(ixName(rival)),city:esc(CITY[c].name)}),'bad');return;}
if(isDk(x)){toast(tr('peering_policy.rival_is_poaching_de_kicks_members',{rival:esc(ixName(rival)),city:esc(CITY[c].name)}),'bad');return;}
S.ixCut=S.ixCut||{};const cur=S.ixCut[x]||1;if(cur<=0.62)return;S.ixCut[x]=+Math.max(0.6,cur*0.9).toFixed(3);
toast(tr('<b>Price war in {city}!</b><br>{ix} cut its port prices 10% to stop members drifting to {rival}. Your invoice just got smaller.',{city:esc(CITY[c].name),ix:esc(ixName(x)),rival:esc(ixName(rival))}),'good');}
toast(tr('peering_policy.price_war_in_city_ix_cut',{city:esc(CITY[c].name),ix:esc(ixName(x)),rival:esc(ixName(rival))}),'good');}