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
@@ -7,7 +7,12 @@ import { createStandaloneControls } from './controls.js';
|
||||
import { createStandaloneData } from './data.js';
|
||||
import { createStandaloneTools } from './tools.js';
|
||||
import { resolveLocale, applyDocumentLanguage } from '../i18n/locale.js';
|
||||
import { applyDocumentTranslations, setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
applyDocumentTranslations,
|
||||
getLocale,
|
||||
onLocaleChange,
|
||||
setLocale,
|
||||
} from '../i18n/index.js';
|
||||
import { mountApplicationViews } from '../ui/views/index.js';
|
||||
import { createGoogleTokenSource } from '../maps/googleTokens.js';
|
||||
|
||||
@@ -31,7 +36,7 @@ export function createStandaloneApplication({
|
||||
// and every catalog lookup agree from the first painted frame. Module
|
||||
// scripts execute after parsing, so the DOM is ready here: the views
|
||||
// translate as they render, and the page's static data-i18n* markup (the
|
||||
// loading screen) is translated once.
|
||||
// loading screen) is translated here and after every language switch.
|
||||
const activeLocale = resolveLocale();
|
||||
setLocale(activeLocale);
|
||||
applyDocumentLanguage(document, activeLocale);
|
||||
@@ -44,6 +49,13 @@ export function createStandaloneApplication({
|
||||
let catalog;
|
||||
return createApplication({
|
||||
createScene: async (context) => {
|
||||
// A language switch applies in place; the page's own markup follows.
|
||||
context.defer(
|
||||
onLocaleChange(() => {
|
||||
applyDocumentLanguage(document, getLocale());
|
||||
applyDocumentTranslations(document);
|
||||
}),
|
||||
);
|
||||
placeSearch = createStandalonePlaceSearch({
|
||||
// The bundled city and landmark data the offline name provider reads.
|
||||
// The search package takes it as plain data rather than importing it,
|
||||
|
||||
Reference in new issue
Block a user