mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
Switch language in place, without a reload
Choosing a language in the picker now applies it at once. The choice is stored and ?lang is kept in step through replaceState, and the picker keeps focus. Code that writes translated text itself re-presents it on a switch: onLocaleChange() lets an owner listen, removed at teardown, and status writers hand over a function of the locale (voice cards, scene director, SDR, draw hints, imagery split, map sources, Bhote Koshi media) so the words are rebuilt rather than re-sent. The HUD, cockpit, radio, CCTV, launch, awareness and credit texts follow the same hook, and applyDocumentTranslations can be applied again without undoing text code wrote since. The unsaved-work registry and persistLocaleAndReload existed only to guard the reload, so they go, with their catalog entries.
This commit is contained in:
1 parent
ba20bc13d8
commit
b20c80e590
87 files changed
+1194
-777
No files matched your search
@@ -32,7 +32,9 @@ import { createBriefState } from './cockpitBriefPages.js';
|
||||
import {
|
||||
createInstrumentState,
|
||||
createRouteState,
|
||||
createVisionState,
|
||||
} from './cockpitInstrumentState.js';
|
||||
import { onLocaleChange } from '../i18n/index.js';
|
||||
import {
|
||||
publishBriefView,
|
||||
showBriefPage,
|
||||
@@ -43,6 +45,7 @@ import {
|
||||
maybeRefreshRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
renderRegionalBrief,
|
||||
relocalizeBrief,
|
||||
} from './cockpitBriefing.js';
|
||||
import {
|
||||
handleSignalClick,
|
||||
@@ -189,7 +192,7 @@ export class CockpitViewController {
|
||||
this.scratchAnchorCartographic = new Cesium.Cartographic();
|
||||
this.scratchCameraCartographic = new Cesium.Cartographic();
|
||||
this.scratchTargetCartographic = new Cesium.Cartographic();
|
||||
this._listenerRemovers = [];
|
||||
this._listenerRemovers = [onLocaleChange(() => this.relocalize())];
|
||||
|
||||
// Camera mutations belong before scene update/culling. Changing the camera
|
||||
// from preRender makes 3D Tiles discover a new view after traversal and can
|
||||
@@ -356,6 +359,9 @@ export class CockpitViewController {
|
||||
renderRegionalBriefStatus(status, info) {
|
||||
return renderRegionalBriefStatus.call(this, status, info);
|
||||
}
|
||||
relocalizeBrief() {
|
||||
return relocalizeBrief.call(this);
|
||||
}
|
||||
renderRegionalBrief(payload, info) {
|
||||
return renderRegionalBrief.call(this, payload, info);
|
||||
}
|
||||
@@ -391,6 +397,36 @@ export class CockpitViewController {
|
||||
return handleSignalClick.call(this, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Word every Cockpit surface again in the current locale. In flight the
|
||||
* last reading is shown again; otherwise the surfaces go back to their
|
||||
* placeholders, which the next entry replaces.
|
||||
*/
|
||||
relocalize() {
|
||||
if (this.destroyed) return;
|
||||
this.relocalizeBrief();
|
||||
this.publishVision(createVisionState(this.visionMode));
|
||||
this.routeSignature = null;
|
||||
if (this.active && this.lastAircraftInfo) {
|
||||
this.rewordingSignals = true;
|
||||
try {
|
||||
this.updateHud(this.lastAircraftInfo, performance.now(), true);
|
||||
} finally {
|
||||
this.rewordingSignals = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.instruments = createInstrumentState();
|
||||
this.publishInstrumentsView();
|
||||
this.routeView = createRouteState();
|
||||
this.publishRouteView();
|
||||
this.contextView = {
|
||||
...createContextState(),
|
||||
weather: this.contextView.weather,
|
||||
};
|
||||
this.publishContextView();
|
||||
}
|
||||
|
||||
/** Revoke new work before the shell awaits layer restoration. */
|
||||
stop() {
|
||||
if (this.destroyed) return;
|
||||
|
||||
Reference in new issue
Block a user