refactor: switch to key-based i18n for choices, revert inline textEn approach

This commit is contained in:
2026-06-09 15:54:55 +08:00
parent 8e7f77bc38
commit f044ed0b60
3 changed files with 3 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, watch, nextTick, computed } from 'vue'
import { ref, watch, nextTick } from 'vue'
import type { Choice } from '@engine/types'
import { useI18n } from '@/composables/useI18n'
@@ -13,12 +13,7 @@ const emit = defineEmits<{
choose: [index: number]
}>()
const { t, currentLang } = useI18n()
function choiceLabel(c: Choice): string {
if (currentLang.value === 'en' && (c as any).textEn) return (c as any).textEn
return c.text
}
const { t } = useI18n()
const focusIndex = ref(0)
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
@@ -80,7 +75,7 @@ function onKeydown(e: KeyboardEvent, index: number) {
@click="emit('choose', index)"
@keydown="onKeydown($event, index)"
>
{{ choiceLabel(choice) }}
{{ t(choice.textKey || choice.text) }}
</button>
</div>
</div>