mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
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:
1 parent
a7d722a1f4
commit
22f43aab01
8 files changed
+17
-51
No files matched your search
@@ -1,12 +1,12 @@
|
|||||||
- Let an application add its own Cockpit subjects through
|
- Let an application add its own Cockpit subjects through
|
||||||
`services.cockpitSubjects`. A provider supplies the subject's position,
|
`services.cockpitSubjects`. A provider supplies the subject's position,
|
||||||
heading and HUD (in the page's language, via the new `./i18n/locale`
|
heading and HUD (in the page's language, via `getLocale` and
|
||||||
export); the camera can follow it without the ground clamp, anchored
|
`onLocaleChange` from `./i18n`); the camera can follow it without the
|
||||||
exactly on it, and a generic HUD adds source rows, a banner, a veil (off
|
ground clamp, anchored exactly on it, and a generic HUD adds source rows, a
|
||||||
under reduced motion) and a bottom progress line. The Rail and Transit
|
banner, a veil (off under reduced motion) and a bottom progress line. The
|
||||||
layers expose read and hold APIs so a selected train or vehicle can be
|
Rail and Transit layers expose read and hold APIs so a selected train or
|
||||||
ridden, and `./layers/rail/paths` is exported; these exports and read APIs
|
vehicle can be ridden, and `./layers/rail/paths` is exported; that export
|
||||||
are experimental. `docs/APPLICATION.md` shows a minimal provider. GEV
|
and the read APIs are experimental. `docs/APPLICATION.md` shows a minimal
|
||||||
itself registers none, and entry to the built-in aircraft, satellite and
|
provider. GEV itself registers none, and entry to the built-in aircraft,
|
||||||
vessel views is unchanged; a provider's subject takes entry when it was
|
satellite and vessel views is unchanged; a provider's subject takes entry
|
||||||
selected after them (Denis Groshev, @ZloyS, #1686).
|
when it was selected after them (Denis Groshev, @ZloyS, #1686).
|
||||||
+3
-3
@@ -248,7 +248,7 @@ their `this`; one that throws or returns a promise is treated as having
|
|||||||
failed.
|
failed.
|
||||||
|
|
||||||
```js
|
```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';
|
import { pointAtS } from '@gods-eye-view/core/layers/rail/paths';
|
||||||
|
|
||||||
const words = {
|
const words = {
|
||||||
@@ -302,7 +302,7 @@ const ride = {
|
|||||||
createApplicationControls({ /* ... */ services: { cockpitSubjects: [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
|
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
|
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
|
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
|
`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
|
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
|
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`,
|
Rail and Transit read APIs (`getSelectedTrain`, `getSelectedVehicle`,
|
||||||
`getCockpitSubject` and the snapshots they return, `path.line` among them)
|
`getCockpitSubject` and the snapshots they return, `path.line` among them)
|
||||||
are experimental and may change without notice.
|
are experimental and may change without notice.
|
||||||
|
|||||||
@@ -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
|
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,
|
line along the bottom edge (`src/cockpitProgress.js`: close ticks merge,
|
||||||
labels never overlap). Core translates none of the provider's text: a host
|
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
|
`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
|
functions, read again when they are shown and on a change of language, as the
|
||||||
HUD view is.
|
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
|
drawn of its train while held, another feed's copy hidden, and it keeps
|
||||||
moving, still selected, when its category is turned off) and
|
moving, still selected, when its category is turned off) and
|
||||||
`focusTrain(key)` (false for a train the layer does not draw); its pure path
|
`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,
|
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
|
and these read APIs are experimental and may change without notice. A snapshot read again while nothing in it changed is
|
||||||
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
|
the one read before, and its `path.line` is a frozen copy. Transit
|
||||||
offers the same for a vehicle (`getSelectedVehicle`, `getCockpitSubject`,
|
offers the same for a vehicle (`getSelectedVehicle`, `getCockpitSubject`,
|
||||||
`setCockpitSubject`, `focusVehicle`): a held vehicle keeps playing when it is
|
`setCockpitSubject`, `focusVehicle`): a held vehicle keeps playing when it is
|
||||||
|
|||||||
@@ -175,7 +175,6 @@
|
|||||||
"./ui/cockpit/math": "./src/cockpitMath.js",
|
"./ui/cockpit/math": "./src/cockpitMath.js",
|
||||||
"./ui/cockpit/layout": "./src/cockpitUtilityLayout.js",
|
"./ui/cockpit/layout": "./src/cockpitUtilityLayout.js",
|
||||||
"./ui/cockpit/vision": "./src/cockpitVisionPolicy.js",
|
"./ui/cockpit/vision": "./src/cockpitVisionPolicy.js",
|
||||||
"./i18n/locale": "./src/i18n/hostLocale.js",
|
|
||||||
"./ui/scenes": "./src/ui/scenes.js",
|
"./ui/scenes": "./src/ui/scenes.js",
|
||||||
"./ui/shell": "./src/ui/applicationShell.js",
|
"./ui/shell": "./src/ui/applicationShell.js",
|
||||||
"./ui/styles": "./src/ui/styles.js",
|
"./ui/styles": "./src/ui/styles.js",
|
||||||
|
|||||||
@@ -1433,7 +1433,6 @@
|
|||||||
"src/cockpitSubjectProviders.test.mjs",
|
"src/cockpitSubjectProviders.test.mjs",
|
||||||
"src/cockpitProgress.js",
|
"src/cockpitProgress.js",
|
||||||
"src/cockpitProgress.test.mjs",
|
"src/cockpitProgress.test.mjs",
|
||||||
"src/i18n/hostLocale.js",
|
|
||||||
"src/ui/cockpitSubjectView.test.mjs",
|
"src/ui/cockpitSubjectView.test.mjs",
|
||||||
"src/ui/styles/cockpitSubject.css",
|
"src/ui/styles/cockpitSubject.css",
|
||||||
"src/layers/rail/cockpitSubject.js",
|
"src/layers/rail/cockpitSubject.js",
|
||||||
|
|||||||
@@ -5898,29 +5898,6 @@
|
|||||||
],
|
],
|
||||||
"external": []
|
"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": {
|
"rail-paths": {
|
||||||
"exports": ["./layers/rail/paths"],
|
"exports": ["./layers/rail/paths"],
|
||||||
"modules": ["src/data/railPaths.js"],
|
"modules": ["src/data/railPaths.js"],
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ function refusal(provider, kinds) {
|
|||||||
* `entryFace`, `labels` and `look` may each be a function returning the
|
* `entryFace`, `labels` and `look` may each be a function returning the
|
||||||
* object: it is called on the provider again whenever they are shown and
|
* 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
|
* 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;
|
* good one; `look` is on or off and `restPitchDeg` fixed as first read;
|
||||||
* - `cameraIntervalMs` (optional): 0..1000, null for the Cockpit's default; 0
|
* - `cameraIntervalMs` (optional): 0..1000, null for the Cockpit's default; 0
|
||||||
* updates the camera every rendered frame;
|
* updates the camera every rendered frame;
|
||||||
|
|||||||
@@ -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';
|
|
||||||
Reference in new issue
Block a user