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

+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.