From 22f43aab01d3f62f882fe10f19ae69f64130bec8 Mon Sep 17 00:00:00 2001 From: Denis Groshev Date: Fri, 13 Nov 2026 07:39:27 +0100 Subject: [PATCH] refactor(cockpit): a provider words its text with getLocale and onLocaleChange from the ./i18n entry; the ./i18n/locale export, which gave only those two, is removed --- changelog.d/1686-cockpit-subjects.md | 20 ++++++++++---------- docs/APPLICATION.md | 6 +++--- docs/CURRENT-STATE.md | 7 +++---- package.json | 1 - scripts/format-scope.json | 1 - scripts/package-boundaries.json | 23 ----------------------- src/cockpitSubjectProviders.js | 2 +- src/i18n/hostLocale.js | 8 -------- 8 files changed, 17 insertions(+), 51 deletions(-) delete mode 100644 src/i18n/hostLocale.js diff --git a/changelog.d/1686-cockpit-subjects.md b/changelog.d/1686-cockpit-subjects.md index f4726dc45..715561e8e 100644 --- a/changelog.d/1686-cockpit-subjects.md +++ b/changelog.d/1686-cockpit-subjects.md @@ -1,12 +1,12 @@ - Let an application add its own Cockpit subjects through `services.cockpitSubjects`. A provider supplies the subject's position, - heading and HUD (in the page's language, via the new `./i18n/locale` - export); the camera can follow it without the ground clamp, anchored - exactly on it, and a generic HUD adds source rows, a banner, a veil (off - under reduced motion) and a bottom progress line. The Rail and Transit - layers expose read and hold APIs so a selected train or vehicle can be - ridden, and `./layers/rail/paths` is exported; these exports and read APIs - are experimental. `docs/APPLICATION.md` shows a minimal provider. GEV - itself registers none, and entry to the built-in aircraft, satellite and - vessel views is unchanged; a provider's subject takes entry when it was - selected after them (Denis Groshev, @ZloyS, #1686). + heading and HUD (in the page's language, via `getLocale` and + `onLocaleChange` from `./i18n`); the camera can follow it without the + ground clamp, anchored exactly on it, and a generic HUD adds source rows, a + banner, a veil (off under reduced motion) and a bottom progress line. The + Rail and Transit layers expose read and hold APIs so a selected train or + vehicle can be ridden, and `./layers/rail/paths` is exported; that export + and the read APIs are experimental. `docs/APPLICATION.md` shows a minimal + provider. GEV itself registers none, and entry to the built-in aircraft, + satellite and vessel views is unchanged; a provider's subject takes entry + when it was selected after them (Denis Groshev, @ZloyS, #1686). diff --git a/docs/APPLICATION.md b/docs/APPLICATION.md index fd7194f50..5f9d74109 100644 --- a/docs/APPLICATION.md +++ b/docs/APPLICATION.md @@ -248,7 +248,7 @@ their `this`; one that throws or returns a promise is treated as having failed. ```js -import { getLocale, onLocaleChange } from '@gods-eye-view/core/i18n/locale'; +import { getLocale, onLocaleChange } from '@gods-eye-view/core/i18n'; import { pointAtS } from '@gods-eye-view/core/layers/rail/paths'; const words = { @@ -302,7 +302,7 @@ const ride = { createApplicationControls({ /* ... */ services: { cockpitSubjects: [ride] } }); ``` -`@gods-eye-view/core/i18n/locale` gives `getLocale()` and `onLocaleChange()`: +The `./i18n` entry gives `getLocale()` and `onLocaleChange()`: Core translates only its own strings, so a provider words its labels, entry face and HUD for the page's language (labels may be functions, as above; the HUD is read again on a change). `@gods-eye-view/core/layers/rail/paths` is the @@ -313,7 +313,7 @@ and Transit read APIs in `src/layers/rail/cockpitSubject.js` and `src/layers/transit/cockpitSubject.js`. A snapshot read again while nothing in it changed is the one read before, so `read` may take one on every update; a train's `path.line` is a frozen copy of its line, for `pointAtS` and -`projectOnPath`. The `i18n/locale` and `layers/rail/paths` exports and the +`projectOnPath`. The `layers/rail/paths` export and the Rail and Transit read APIs (`getSelectedTrain`, `getSelectedVehicle`, `getCockpitSubject` and the snapshots they return, `path.line` among them) are experimental and may change without notice. diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 864f2380e..3ad5c6c26 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -2251,7 +2251,7 @@ picture under the HUD (with passing light streaks, which stop under reduced motion), arrow-key look-around when the provider asks for it, and a progress line along the bottom edge (`src/cockpitProgress.js`: close ticks merge, labels never overlap). Core translates none of the provider's text: a host -words it for the page's language (`@gods-eye-view/core/i18n/locale`: +words it for the page's language (`@gods-eye-view/core/i18n`: `getLocale`, `onLocaleChange`). Its entry face, labels and look may be functions, read again when they are shown and on a change of language, as the HUD view is. @@ -2267,9 +2267,8 @@ feed held, clicks and Escape left to the view; the held copy stays the one drawn of its train while held, another feed's copy hidden, and it keeps moving, still selected, when its category is turned off) and `focusTrain(key)` (false for a train the layer does not draw); its pure path -module is exported as `@gods-eye-view/core/layers/rail/paths`. That export, -`@gods-eye-view/core/i18n/locale` and these read APIs are experimental and may -change without notice. A snapshot read again while nothing in it changed is +module is exported as `@gods-eye-view/core/layers/rail/paths`. That export +and these read APIs are experimental and may change without notice. A snapshot read again while nothing in it changed is the one read before, and its `path.line` is a frozen copy. Transit offers the same for a vehicle (`getSelectedVehicle`, `getCockpitSubject`, `setCockpitSubject`, `focusVehicle`): a held vehicle keeps playing when it is diff --git a/package.json b/package.json index b434fa843..7559b1ddd 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,6 @@ "./ui/cockpit/math": "./src/cockpitMath.js", "./ui/cockpit/layout": "./src/cockpitUtilityLayout.js", "./ui/cockpit/vision": "./src/cockpitVisionPolicy.js", - "./i18n/locale": "./src/i18n/hostLocale.js", "./ui/scenes": "./src/ui/scenes.js", "./ui/shell": "./src/ui/applicationShell.js", "./ui/styles": "./src/ui/styles.js", diff --git a/scripts/format-scope.json b/scripts/format-scope.json index ab609077c..b9528bc87 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -1433,7 +1433,6 @@ "src/cockpitSubjectProviders.test.mjs", "src/cockpitProgress.js", "src/cockpitProgress.test.mjs", - "src/i18n/hostLocale.js", "src/ui/cockpitSubjectView.test.mjs", "src/ui/styles/cockpitSubject.css", "src/layers/rail/cockpitSubject.js", diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index 4b9850a17..20fef3d73 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -5898,29 +5898,6 @@ ], "external": [] }, - "i18n-locale": { - "exports": ["./i18n/locale"], - "modules": [ - "src/i18n/hostLocale.js", - "src/i18n/marker.js", - "src/i18n/index.js", - "src/i18n/locale.js", - "src/i18n/locales/ar.json", - "src/i18n/locales/de.json", - "src/i18n/locales/es.json", - "src/i18n/locales/fr.json", - "src/i18n/locales/he.json", - "src/i18n/locales/it.json", - "src/i18n/locales/ja.json", - "src/i18n/locales/pt.json", - "src/i18n/locales/ru.json", - "src/i18n/locales/sv.json", - "src/i18n/locales/uk.json", - "src/i18n/locales/zh-CN.json", - "src/i18n/locales/zh-Hant.json" - ], - "external": [] - }, "rail-paths": { "exports": ["./layers/rail/paths"], "modules": ["src/data/railPaths.js"], diff --git a/src/cockpitSubjectProviders.js b/src/cockpitSubjectProviders.js index a8620bea4..aca759662 100644 --- a/src/cockpitSubjectProviders.js +++ b/src/cockpitSubjectProviders.js @@ -167,7 +167,7 @@ function refusal(provider, kinds) { * `entryFace`, `labels` and `look` may each be a function returning the * object: it is called on the provider again whenever they are shown and * when the page's language changes, so its words can follow it - * (`./i18n/locale`). A read that throws or is malformed keeps the last + * (`./i18n`). A read that throws or is malformed keeps the last * good one; `look` is on or off and `restPitchDeg` fixed as first read; * - `cameraIntervalMs` (optional): 0..1000, null for the Cockpit's default; 0 * updates the camera every rendered frame; diff --git a/src/i18n/hostLocale.js b/src/i18n/hostLocale.js deleted file mode 100644 index 5e05e3a07..000000000 --- a/src/i18n/hostLocale.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * The page's language, for an application that words its own text beside - * Core's: read the active locale, and hear when it changes. Core translates - * only its own strings; text an application hands Core (a cockpit subject - * provider's labels and HUD view, say) is shown as given, so the application - * words it for `getLocale()` and words it again on `onLocaleChange`. - */ -export { getLocale, onLocaleChange } from './index.js';