fix: remove scene. prefix from textKey, add fallback to choice.text when locale key missing
This commit is contained in:
@@ -17,6 +17,14 @@ const emit = defineEmits<{
|
||||
|
||||
const { t } = useI18n()
|
||||
const store = useGameStore()
|
||||
|
||||
function choiceText(choice: Choice): string {
|
||||
if (choice.textKey) {
|
||||
const translated = t(choice.textKey)
|
||||
if (translated !== choice.textKey) return translated
|
||||
}
|
||||
return choice.text.trim() || choice.textKey || ''
|
||||
}
|
||||
const focusIndex = ref(0)
|
||||
const btnRefs = ref<(HTMLButtonElement | null)[]>([])
|
||||
const choiceEnabled = ref(!store.antiMistap)
|
||||
@@ -96,7 +104,7 @@ function handleChoose(index: number) {
|
||||
@click="handleChoose(index)"
|
||||
@keydown="onKeydown($event, index)"
|
||||
>
|
||||
{{ t(choice.textKey || choice.text) }}
|
||||
{{ choiceText(choice) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user