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
@@ -61,7 +61,7 @@ const removeTitle = (title) =>
|
||||
<span data-key-setup-chip-label>{{ chip ? chip.label : t('POWER UP') }}</span>
|
||||
</button>
|
||||
</Teleport>
|
||||
<LocalePicker v-if="picker" :key="picker.current" :current="picker.current" :on-select="picker.onSelect" />
|
||||
<LocalePicker v-if="picker" :key="picker.current" :current="picker.current" :on-select="picker.onSelect" :focus="picker.focus" />
|
||||
</div>
|
||||
<aside v-if="available" id="key-setup" role="dialog" aria-labelledby="key-setup-title" aria-describedby="key-setup-description" :hidden="dialog.hidden" v-class-toggle="{ visible: dialog.visible }" :data-ready="view?.ready ? 'true' : undefined" @transitionend="controls?.transitionEnd()">
|
||||
<div class="key-setup-scanline" aria-hidden="true"></div>
|
||||
|
||||
@@ -39,20 +39,20 @@ const celestialTitle = computed(() =>
|
||||
);
|
||||
const models3dOn = computed(() => models3d.value?.pressed ?? true);
|
||||
const modelsMode = computed(() => models3d.value?.mode ?? 'proximity');
|
||||
const modelsOptions = [
|
||||
const modelsOptions = computed(() => [
|
||||
{ value: 'proximity', label: t('Proximity'), attrs: { id: 'models3d-mode-proximity', 'data-mode': 'proximity' } },
|
||||
{ value: 'all', label: t('All'), attrs: { id: 'models3d-mode-all', 'data-mode': 'all' } },
|
||||
];
|
||||
]);
|
||||
const drawShape = computed(() => draw.value?.shape ?? 'area');
|
||||
const drawShapeOptions = [
|
||||
const drawShapeOptions = computed(() => [
|
||||
{ value: 'area', label: t('Area'), attrs: { 'data-shape': 'area' } },
|
||||
{ value: 'line', label: t('Line'), attrs: { 'data-shape': 'line' } },
|
||||
{ value: 'pin', label: t('Pin'), attrs: { 'data-shape': 'pin' } },
|
||||
];
|
||||
const allocationOptions = [
|
||||
]);
|
||||
const allocationOptions = computed(() => [
|
||||
{ value: 'ELASTIC', label: t('Elastic'), attrs: { id: 'detection-allocation-elastic', 'data-allocation': 'ELASTIC' } },
|
||||
{ value: 'WEIGHTED', label: t('Weighted'), attrs: { id: 'detection-allocation-weighted', 'data-allocation': 'WEIGHTED' } },
|
||||
];
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
computed,
|
||||
nextTick,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
shallowRef,
|
||||
useTemplateRef,
|
||||
} from 'vue';
|
||||
@@ -23,6 +24,8 @@ import { vClassToggle } from '../../rail/classToggle.js';
|
||||
const props = defineProps({
|
||||
current: { type: String, required: true },
|
||||
onSelect: { type: Function, required: true },
|
||||
/** Focus the button once drawn: the picker is drawn again after a choice. */
|
||||
focus: { type: Boolean, default: false },
|
||||
locales: { type: Array, default: () => LOCALES },
|
||||
nativeNames: { type: Object, default: () => LOCALE_NAMES },
|
||||
searchThreshold: { type: Number, default: LOCALE_SEARCH_THRESHOLD },
|
||||
@@ -73,9 +76,11 @@ const focusTarget = () => search.value || listbox.value;
|
||||
const activeDescendant = computed(() =>
|
||||
view.value.active ? ids.option(view.value.active) : undefined,
|
||||
);
|
||||
const buttonLabel = t('Language: {language}', {
|
||||
language: props.nativeNames[props.current] || props.current,
|
||||
});
|
||||
const buttonLabel = computed(() =>
|
||||
t('Language: {language}', {
|
||||
language: props.nativeNames[props.current] || props.current,
|
||||
}),
|
||||
);
|
||||
|
||||
let swallowSpaceKeyup = false;
|
||||
|
||||
@@ -88,7 +93,7 @@ function close({ restoreFocus = false } = {}) {
|
||||
if (restoreFocus) button.value?.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
// The shell may ask before switching; the list is closed on screen first.
|
||||
// The list is closed on screen before the shell switches.
|
||||
async function choose(code) {
|
||||
close({ restoreFocus: true });
|
||||
if (code === props.current) return;
|
||||
@@ -173,6 +178,9 @@ function onFocusOut(event) {
|
||||
if (model.open && next && !root.value?.contains(next)) close();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.focus) button.value?.focus({ preventScroll: true });
|
||||
});
|
||||
onBeforeUnmount(() => close());
|
||||
|
||||
defineExpose({ open, close, isOpen: () => model.open });
|
||||
|
||||
@@ -27,12 +27,12 @@ const setFilter = (select) => {
|
||||
// its own frames.
|
||||
const sdrConnected = computed(() => sdr.value?.connectionActive ?? null);
|
||||
// The collapse button keeps Radio's own wording, not "Expand RADIO".
|
||||
const radioWords = {
|
||||
const radioWords = computed(() => ({
|
||||
expandLabel: t('Expand Radio section'),
|
||||
collapseLabel: t('Collapse Radio section'),
|
||||
expandTitle: t('Expand Radio'),
|
||||
collapseTitle: t('Collapse Radio'),
|
||||
};
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -38,7 +38,7 @@ const shows = computed(
|
||||
);
|
||||
const pano = computed(() => view.value?.filter.pano ?? 'all');
|
||||
|
||||
const renderModeOptions = [
|
||||
const renderModeOptions = computed(() => [
|
||||
{
|
||||
value: 'letterbox',
|
||||
label: t('FIT'),
|
||||
@@ -55,12 +55,12 @@ const renderModeOptions = [
|
||||
title: t('Fill: fill the frame edge to edge, cropping the photo'),
|
||||
},
|
||||
},
|
||||
];
|
||||
const panoOptions = [
|
||||
]);
|
||||
const panoOptions = computed(() => [
|
||||
{ value: 'all', label: t('ALL'), attrs: { 'data-sl-pano': 'all' } },
|
||||
{ value: 'pano', label: '360°', attrs: { 'data-sl-pano': 'pano' } },
|
||||
{ value: 'flat', label: t('FLAT'), attrs: { 'data-sl-pano': 'flat' } },
|
||||
];
|
||||
]);
|
||||
|
||||
// The image line and OPEN keep what they last showed while hidden.
|
||||
const image = shallowRef({
|
||||
|
||||
Reference in new issue
Block a user