mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52:21 +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
@@ -8,7 +8,11 @@ import {
|
||||
formatCockpitCoordinate,
|
||||
formatCockpitWindDirection,
|
||||
} from './cockpitPresentation.js';
|
||||
import { COCKPIT_BRIEF_PAGES, CYCLE_HELP_KEYS } from './cockpitBriefPages.js';
|
||||
import {
|
||||
COCKPIT_BRIEF_PAGES,
|
||||
CYCLE_HELP_KEYS,
|
||||
createBriefState,
|
||||
} from './cockpitBriefPages.js';
|
||||
|
||||
// regionalModel.weatherCodeLabel is shared with node code and returns
|
||||
// English; translate it here.
|
||||
@@ -58,15 +62,41 @@ export function showBriefPage(index, { manual = false } = {}) {
|
||||
this.scheduleContextLayout();
|
||||
}
|
||||
|
||||
// The state is the accessible name; the help is the tooltip.
|
||||
function cycleWords(enabled) {
|
||||
return {
|
||||
autoRotate: enabled,
|
||||
autoLabel: enabled ? t('CYCLE ON') : t('CYCLE OFF'),
|
||||
autoHelp: t(CYCLE_HELP_KEYS[enabled ? 'on' : 'off']),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Word the briefing again in the current locale: its page, cycle toggle and
|
||||
* whatever the regional card shows.
|
||||
*/
|
||||
export function relocalizeBrief() {
|
||||
if (this.destroyed) return;
|
||||
if (this.brief.news.state === null) {
|
||||
const { news, local } = createBriefState();
|
||||
this.brief.news = news;
|
||||
this.brief.local = { ...local, coordinates: this.brief.local.coordinates };
|
||||
}
|
||||
Object.assign(this.brief, cycleWords(this.briefAutoRotateEnabled));
|
||||
this.showBriefPage(this.briefPageIndex);
|
||||
if (this.regionalBrief)
|
||||
this.renderRegionalBrief(this.regionalBrief, this.lastAircraftInfo);
|
||||
else if (this.brief.news.state)
|
||||
this.renderRegionalBriefStatus(
|
||||
this.brief.news.state,
|
||||
this.lastAircraftInfo,
|
||||
);
|
||||
}
|
||||
|
||||
export function setBriefAutoRotate(enabled) {
|
||||
if (this.destroyed) return;
|
||||
this.briefAutoRotateEnabled = Boolean(enabled);
|
||||
// The state is the accessible name; the help is the tooltip.
|
||||
Object.assign(this.brief, {
|
||||
autoRotate: this.briefAutoRotateEnabled,
|
||||
autoLabel: this.briefAutoRotateEnabled ? t('CYCLE ON') : t('CYCLE OFF'),
|
||||
autoHelp: t(CYCLE_HELP_KEYS[this.briefAutoRotateEnabled ? 'on' : 'off']),
|
||||
});
|
||||
Object.assign(this.brief, cycleWords(this.briefAutoRotateEnabled));
|
||||
this.publishBriefView();
|
||||
if (this.briefAutoRotateEnabled) this.startBriefRotation({ reset: true });
|
||||
else this.stopBriefRotation();
|
||||
|
||||
Reference in new issue
Block a user