refactor: switch to key-based i18n for choices, revert inline textEn approach
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user