feat(i18n): presentation extraction — t() call sites, data-i18n templates, locale selector

Route every application-owned presentation string through the i18n
core: t() call sites across the app/layers/ui/data/voice surfaces,
data-i18n* attributes in the src/ui/templates/*.html markup (applied at
boot by applyDocumentTranslations from src/standalone/application.js),
and the dock locale selector (runtime-rendered from the offered pair —
a single EN button while only English ships).

Rebased onto current main, where the extraction follows the module
splits: the shell wiring now lands in the owner modules
(panelChrome, visualSettings, locationNavigation, shareRestoration,
shellFeedback, applicationShell) and the voice status corpus in the
realtime* modules; scene status lives in director.js +
playbackAdapter.js.

Modules shared with the node runtime (loadingFeedback,
installationFeedback, regionalModel, keySetupCore, vessels ingestion)
stay environment-neutral English and localize at their browser render
sites (chip maps in shellFeedback/installations controls, the weather
table in cockpitBriefing, keySetupRequirementEnvVars compositions), so
the package-boundary graph stays clean; the browser boundary groups
now own the i18n modules they reach (scripts/package-boundaries.json).
This commit is contained in:
Meir Michanie committed 2026-10-01 12:41:20 +02:00
1 parent bde1e430ef
commit 284c4d4601
98 files changed
+3474 -1625

No files matched your search

+1 -1
View File
@@ -301,7 +301,7 @@ test('Contacts continuation target is the visible explanatory note', () => {
const source = readLayerSource(new URL('./militaryAwareness.js', import.meta.url));
assert.match(
source,
/<p class="military-awareness-note" tabindex="-1" data-awareness-focus-continuation>Open-source mapped\/observed context\./,
/<p class="military-awareness-note" tabindex="-1" data-awareness-focus-continuation>\$\{t\('layers\.awareness\.note'\)\}<\/p>/,
);
assert.doesNotMatch(source, /<span[^>]*data-awareness-focus-continuation/);
});
+6 -4
View File
@@ -1,5 +1,7 @@
/** Pure proximity helpers for Global Context. No capability modeling. */
import { t } from '../i18n/index.js';
export const AWARENESS_RADIUS_M = 250000;
export const AWARENESS_MAX_FLIGHT_SEARCH_RADIUS_M = 16000000;
export const AWARENESS_RELATIONSHIP = Object.freeze({
@@ -82,14 +84,14 @@ export function summarizeAwarenessCohort(
relationship: AWARENESS_RELATIONSHIP.UNKNOWN,
count: null,
nearest: [],
reason: 'feed unavailable',
reason: t('layers.awareness.reason.feedUnavailable'),
};
if (stale)
return {
relationship: AWARENESS_RELATIONSHIP.UNKNOWN,
count: null,
nearest: [],
reason: 'feed stale',
reason: t('layers.awareness.reason.feedStale'),
};
const normalized = (Array.isArray(items) ? items : [])
.filter(
@@ -106,8 +108,8 @@ export function summarizeAwarenessCohort(
count: normalized.length,
nearest: normalized.slice(0, limit),
reason: normalized.length
? 'observed or mapped nearby context'
: 'no observed or mapped objects in current feeds',
? t('layers.awareness.reason.nearby')
: t('layers.awareness.reason.none'),
};
}
+32 -3
View File
@@ -17,6 +17,8 @@
* for), then the constellations users can actually name, then the grab-bag.
*/
import { t } from '../i18n/index.js';
/**
* Class registry. `label` is the card/legend token, `color` the point color,
* `blurb` the plain-language gloss for the legend tooltip.
@@ -77,6 +79,32 @@ export const SATELLITE_CLASS_ORDER = Object.freeze([
'comms',
]);
// Display keys for the class table above: `label`/`blurb` stay the English
// source-of-truth tokens (tests read them), while the card and legend accessors
// translate through these keys at the presentation boundary.
const CLASS_DISPLAY_KEYS = Object.freeze({
station: Object.freeze({
label: 'layers.satellites.class.station',
blurb: 'layers.satellites.class.stationBlurb',
}),
nav: Object.freeze({
label: 'layers.satellites.class.nav',
blurb: 'layers.satellites.class.navBlurb',
}),
geo: Object.freeze({
label: 'layers.satellites.class.geo',
blurb: 'layers.satellites.class.geoBlurb',
}),
visual: Object.freeze({
label: 'layers.satellites.class.visual',
blurb: 'layers.satellites.class.visualBlurb',
}),
comms: Object.freeze({
label: 'layers.satellites.class.comms',
blurb: 'layers.satellites.class.commsBlurb',
}),
});
/**
* CelesTrak group tag → { class, subtype }. Subtype names the specific
* constellation so the card can read "NAV · GPS" rather than a bare "NAV".
@@ -139,7 +167,7 @@ export function satelliteClassColor(group) {
*/
export function satelliteClassLabel(group, { isIss = false } = {}) {
const { klass, subtype } = satelliteClassOf(group, { isIss });
const base = SATELLITE_CLASSES[klass].label;
const base = t(CLASS_DISPLAY_KEYS[klass].label);
return subtype ? `${base} · ${subtype}` : base;
}
@@ -180,11 +208,12 @@ export function satelliteClassLegend(counts) {
const count = counts?.[klass];
if (!(count > 0)) continue;
const spec = SATELLITE_CLASSES[klass];
const display = CLASS_DISPLAY_KEYS[klass];
result.push({
klass,
label: spec.label,
label: t(display.label),
color: spec.color,
blurb: spec.blurb,
blurb: t(display.blurb),
count,
});
}
+39
View File
@@ -4,6 +4,8 @@
* after the vessel cards moved out of their dedicated canvas renderer.
*/
import { t } from '../i18n/index.js';
export const VESSEL_OVERLAY_SOURCE_ID = 'ais-live-vessels';
/** Existing selector grid size; one ambient winner is retained per cell. */
export const VESSEL_LABEL_GRID_PX = 118;
@@ -64,6 +66,43 @@ const NUMERIC_TYPE_FAMILIES = {
9: 'OTHER',
};
// Display keys for the normalized English type tokens above. The tokens stay
// machine values — TYPE_STYLES matches on them and tests pin them — so card
// text translates only through this map at the presentation boundary.
const TYPE_DISPLAY_KEYS = Object.freeze({
FISHING: 'layers.vessel.type.fishing',
TOWING: 'layers.vessel.type.towing',
DREDGER: 'layers.vessel.type.dredger',
'DIVE OPS': 'layers.vessel.type.diveOps',
MILITARY: 'layers.vessel.type.military',
SAILING: 'layers.vessel.type.sailing',
PLEASURE: 'layers.vessel.type.pleasure',
PILOT: 'layers.vessel.type.pilot',
SAR: 'layers.vessel.type.sar',
TUG: 'layers.vessel.type.tug',
'PORT TENDER': 'layers.vessel.type.portTender',
'ANTI-POLLUTION': 'layers.vessel.type.antiPollution',
'LAW ENFORCE': 'layers.vessel.type.lawEnforce',
MEDICAL: 'layers.vessel.type.medical',
'HIGH-SPEED': 'layers.vessel.type.highSpeed',
PASSENGER: 'layers.vessel.type.passenger',
CARGO: 'layers.vessel.type.cargo',
TANKER: 'layers.vessel.type.tanker',
OTHER: 'layers.vessel.type.other',
});
/**
* Card-display form of a normalized AIS type: known tokens translate through
* the catalog; free-text types and unknown codes render unchanged.
* @param {string} type Raw AIS type.
* @returns {string}
*/
export function displayVesselType(type) {
const normalized = normalizeVesselType(type);
const key = TYPE_DISPLAY_KEYS[normalized.toUpperCase()];
return key ? t(key) : normalized;
}
/**
* Resolve an AIS type to display text: bare numeric ship-type codes map to
* family names ("71" → "CARGO"); text types pass through unchanged.