mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +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.
55 lines
1.8 KiB
Vue
55 lines
1.8 KiB
Vue
<script setup>
|
||
import { computed } from 'vue';
|
||
import { msg, t } from '../../i18n/index.js';
|
||
import UiButton from './UiButton.vue';
|
||
|
||
// A panel's collapse button, internal to the kit: UiPanel draws it, and so
|
||
// does PanelCollapseButton for the panels not built on UiPanel. Its glyph and
|
||
// words follow `collapsed`; a click asks for the other state.
|
||
const props = defineProps({
|
||
/** The panel's id, which PanelChrome finds the button by. */
|
||
target: { type: String, required: true },
|
||
/** The panel's name in "Expand {name}", already translated; "panel" when unset. */
|
||
name: { type: String, default: null },
|
||
collapsed: { type: Boolean, required: true },
|
||
/** A right-rail panel opens and closes sideways: ◀ / ▶, not + / −. */
|
||
sideways: { type: Boolean, default: false },
|
||
/** Words that replace "Expand/Collapse {name}" (Radio's own wording). */
|
||
words: { type: Object, default: null },
|
||
});
|
||
const emit = defineEmits(['update:collapsed']);
|
||
|
||
const glyph = computed(() => {
|
||
if (props.sideways) return props.collapsed ? '◀' : '▶';
|
||
return props.collapsed ? '+' : '−';
|
||
});
|
||
const label = computed(() => {
|
||
if (props.words)
|
||
return props.collapsed
|
||
? props.words.expandLabel
|
||
: props.words.collapseLabel;
|
||
const key = props.collapsed ? msg('Expand {name}') : msg('Collapse {name}');
|
||
return t(key, { name: props.name ?? t('panel') });
|
||
});
|
||
const title = computed(() => {
|
||
if (props.words)
|
||
return props.collapsed
|
||
? props.words.expandTitle
|
||
: props.words.collapseTitle;
|
||
return label.value;
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<UiButton
|
||
variant="icon"
|
||
class="panel-collapse-btn"
|
||
:data-collapse-target="target"
|
||
:label="label"
|
||
:title="title"
|
||
:aria-expanded="String(!collapsed)"
|
||
@click="emit('update:collapsed', !collapsed)"
|
||
>{{ glyph }}</UiButton
|
||
>
|
||
</template>
|