mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +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
+14
-5
@@ -68,7 +68,7 @@ export function createVoicePanelHost({
|
||||
};
|
||||
const renderActivity = () => {
|
||||
ui.update('preferences', {
|
||||
timeoutStatus:
|
||||
timeoutStatus: () =>
|
||||
nativeProvider === 'openai' || nativeProvider === 'gemini'
|
||||
? ''
|
||||
: t('Automatic stop is unavailable for this voice connection.'),
|
||||
@@ -234,9 +234,14 @@ export function createVoicePanelHost({
|
||||
card,
|
||||
getPreviewEnabled: () => preferences.snapshot().previewEnabled,
|
||||
getCockpitActive: () => readCockpitState()?.active === true,
|
||||
// Getters, so the panel words them in the current locale.
|
||||
copy: {
|
||||
previewEmpty: t('Voice replies appear here.'),
|
||||
previewDisabled: t('Preview is off.'),
|
||||
get previewEmpty() {
|
||||
return t('Voice replies appear here.');
|
||||
},
|
||||
get previewDisabled() {
|
||||
return t('Preview is off.');
|
||||
},
|
||||
},
|
||||
onPresentationIntent: remember,
|
||||
});
|
||||
@@ -245,8 +250,12 @@ export function createVoicePanelHost({
|
||||
preferences,
|
||||
copy: {
|
||||
previewNote: '',
|
||||
timeoutNote: t('These preferences stay in this browser.'),
|
||||
notSaved: t('Your choice applies now, but could not be saved.'),
|
||||
get timeoutNote() {
|
||||
return t('These preferences stay in this browser.');
|
||||
},
|
||||
get notSaved() {
|
||||
return t('Your choice applies now, but could not be saved.');
|
||||
},
|
||||
},
|
||||
onChange: (state) => {
|
||||
if (!owns()) return;
|
||||
|
||||
@@ -59,9 +59,10 @@ export function createManualVoicePanel({
|
||||
selected: view,
|
||||
});
|
||||
card?.setPresented?.(open && view === 'preview' && !suppressed());
|
||||
const previewOn = enabled();
|
||||
ui.update('previewEmpty', {
|
||||
hidden: ui.state.card.visible,
|
||||
text: enabled() ? copy.previewEmpty : copy.previewDisabled,
|
||||
text: () => (previewOn ? copy.previewEmpty : copy.previewDisabled),
|
||||
});
|
||||
if (restoreFocus) void ui.focus(['settingsButton', 'button']);
|
||||
};
|
||||
|
||||
@@ -120,8 +120,11 @@ export function bindPreferenceControls({ ui, preferences, copy, onChange }) {
|
||||
if (customSelected) custom = state.minutes;
|
||||
ui.update('preferences', {
|
||||
previewChecked: state.previewEnabled,
|
||||
previewNote: `${copy.previewNote}${state.previewPersisted === false ? ` ${copy.notSaved}` : ''}`,
|
||||
timeoutNote: `${copy.timeoutNote}${state.timeoutPersisted === false ? ` ${copy.notSaved}` : ''}`,
|
||||
// Functions, so a locale change words the notes again.
|
||||
previewNote: () =>
|
||||
`${copy.previewNote}${state.previewPersisted === false ? ` ${copy.notSaved}` : ''}`,
|
||||
timeoutNote: () =>
|
||||
`${copy.timeoutNote}${state.timeoutPersisted === false ? ` ${copy.notSaved}` : ''}`,
|
||||
timeoutChoice:
|
||||
state.minutes === 0 ? '0' : customSelected ? 'custom' : value,
|
||||
timeoutMinutes: String(custom),
|
||||
|
||||
Reference in new issue
Block a user