mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +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,6 @@ import {
|
||||
initKeySetup,
|
||||
} from './keySetup.js';
|
||||
import { createPinia } from 'pinia';
|
||||
import { describeUnsavedWork } from './i18n/index.js';
|
||||
import { useProviderSettingsStore } from './ui/stores/providerSettings.js';
|
||||
|
||||
const freshStore = () => useProviderSettingsStore(createPinia());
|
||||
@@ -129,31 +128,3 @@ test('aborting pending setup removes its surface and ignores a late response', a
|
||||
assert.equal(await pending, null);
|
||||
assert.equal(store.view.available, false);
|
||||
});
|
||||
|
||||
test('a pasted, unsaved key makes the language switch ask first until teardown', async () => {
|
||||
const store = freshStore();
|
||||
const root = { dataset: {} };
|
||||
const controller = new AbortController();
|
||||
const setup = await initKeySetup({
|
||||
documentRef: {
|
||||
getElementById: (id) => (id === 'key-setup' ? root : null),
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
},
|
||||
signal: controller.signal,
|
||||
store,
|
||||
fetchImpl: async () => ({
|
||||
ok: true,
|
||||
json: async () => ({ keys: [], setCount: 0, total: 1 }),
|
||||
}),
|
||||
});
|
||||
assert.ok(setup);
|
||||
assert.deepEqual(describeUnsavedWork(), []);
|
||||
store.controls.setField('GOOGLE_MAPS_API_KEY', ' ');
|
||||
assert.deepEqual(describeUnsavedWork(), []);
|
||||
store.controls.setField('GOOGLE_MAPS_API_KEY', 'AIza-pasted');
|
||||
assert.deepEqual(describeUnsavedWork(), ['unsaved provider keys']);
|
||||
// The field still holds the key, so only teardown dropping the check clears it.
|
||||
controller.abort();
|
||||
assert.deepEqual(describeUnsavedWork(), []);
|
||||
});
|
||||
Reference in new issue
Block a user