mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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.
20 lines
697 B
JavaScript
20 lines
697 B
JavaScript
import { defineStore } from 'pinia';
|
|
import { markRaw, shallowRef } from 'vue';
|
|
|
|
/**
|
|
* The interface language picker as its view renders it. The shell publishes
|
|
* the active language and what a choice does once it decides to show the
|
|
* picker; a host that does not initialize Core's locale never does.
|
|
*/
|
|
export const useLocaleStore = defineStore('gev-locale', () => {
|
|
/** `{current, onSelect, focus}`, or null while no picker is shown. */
|
|
const picker = shallowRef(null);
|
|
|
|
/** @param {?{current: string, onSelect: (locale: string) => void, focus?: boolean}} next */
|
|
function publishPicker(next) {
|
|
picker.value = next && markRaw(next);
|
|
}
|
|
|
|
return { picker, publishPicker };
|
|
});
|