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

This commit is contained in:
Denis Groshev committed 2026-11-13 07:39:27 +01:00
1 parent a7d722a1f4
commit 22f43aab01
8 files changed
+17 -51

No files matched your search

+10 -10
View File
@@ -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).
+3 -3
View File
@@ -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.
+3 -4
View File
@@ -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
-1
View File
@@ -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",
-1
View File
@@ -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",
-23
View File
@@ -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"],
+1 -1
View File
@@ -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;
-8
View File
@@ -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';