feat: i18n for choice prompt via promptKey, with fallback

This commit is contained in:
2026-06-10 16:51:50 +08:00
parent 879501ccb5
commit 03c4ee3a65
6 changed files with 22 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ export interface Choice {
text: string
textKey?: string
prompt?: string
promptKey?: string
targetScene: string
conditions?: Condition[]
effects?: Effect[]

View File

@@ -11,6 +11,9 @@
"choice": {
"handshake": "Shake hands with the stranger",
"reject": "Refuse to shake, stay alert"
},
"prompt": {
"handshake": "The stranger will remember your kindness"
}
},
"right_door": {
@@ -26,6 +29,9 @@
"choice": {
"journey": "Embark on a journey of trust (requires trust >= 80)",
"leave": "Leave this place"
},
"prompt": {
"journey": "Your bond will change everything"
}
},
"investigation_site": {

View File

@@ -11,6 +11,9 @@
"choice": {
"handshake": "見知らぬ人と握手する",
"reject": "握手を断り、警戒を続ける"
},
"prompt": {
"handshake": "見知らぬ人はあなたの優しさを覚えている"
}
},
"right_door": {
@@ -26,6 +29,9 @@
"choice": {
"journey": "信頼の旅に出るtrust >= 80 が必要)",
"leave": "ここを去る"
},
"prompt": {
"journey": "あなたの絆が全てを変える"
}
},
"investigation_site": {

View File

@@ -11,6 +11,9 @@
"choice": {
"handshake": "与陌生人握手",
"reject": "拒绝握手,保持警惕"
},
"prompt": {
"handshake": "陌生人会记住你的善意"
}
},
"right_door": {
@@ -26,6 +29,9 @@
"choice": {
"journey": "开启信任的旅程(需要 trust >= 80",
"leave": "离开这里"
},
"prompt": {
"journey": "你们的羁绊将改变一切"
}
},
"investigation_site": {

View File

@@ -211,6 +211,7 @@
"text": "与陌生人握手",
"textKey": "left_door.choice.handshake",
"prompt": "陌生人会记住你的善意",
"promptKey": "left_door.prompt.handshake",
"targetScene": "trust_ending",
"effects": [
{ "type": "add", "target": "trust", "value": 30 }
@@ -322,6 +323,7 @@
"text": "开启信任的旅程(需要 trust >= 80",
"textKey": "trust_ending.choice.journey",
"prompt": "你们的羁绊将改变一切",
"promptKey": "trust_ending.prompt.journey",
"targetScene": "secret_ending",
"conditions": [
{ "variable": "trust", "op": ">=", "value": 80 }

View File

@@ -77,7 +77,7 @@ function handleChoose(index: number) {
if (!choiceEnabled.value) return
const choice = props.choices[index]
if (choice?.prompt) {
emit('prompt', choice.prompt)
emit('prompt', t(choice.promptKey || choice.prompt))
}
emit('choose', index)
}