Commit c0b1d41c authored by BBeretta's avatar BBeretta

feat/language-translation (error message, interactions string)

parent 8d8d1213
...@@ -14,6 +14,9 @@ const DECKERROR_EXTRACOUNT = 0x7; ...@@ -14,6 +14,9 @@ const DECKERROR_EXTRACOUNT = 0x7;
const DECKERROR_SIDECOUNT = 0x8; const DECKERROR_SIDECOUNT = 0x8;
const DECKERROR_NOTAVAIL = 0x9; const DECKERROR_NOTAVAIL = 0x9;
const language = localStorage.getItem('language');
const mainDeckWarining = language === 'en' ? 'The main deck should contain 40-60 cards.' : '主卡组数量应为40-60张';
export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) { export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
const { error_type, error_code } = errorMsg; const { error_type, error_code } = errorMsg;
switch (error_type) { switch (error_type) {
...@@ -55,7 +58,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) { ...@@ -55,7 +58,7 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
break; break;
} }
case DECKERROR_MAINCOUNT: { case DECKERROR_MAINCOUNT: {
roomStore.errorMsg = "主卡组数量应为40-60张"; roomStore.errorMsg = mainDeckWarining;
break; break;
} }
case DECKERROR_EXTRACOUNT: { case DECKERROR_EXTRACOUNT: {
......
...@@ -33,6 +33,7 @@ import styles from "./index.module.scss"; ...@@ -33,6 +33,7 @@ import styles from "./index.module.scss";
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType; import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
import { clearAllIdleInteractivities, clearSelectInfo } from "../../utils"; import { clearAllIdleInteractivities, clearSelectInfo } from "../../utils";
import { openChatBox } from "../ChatBox"; import { openChatBox } from "../ChatBox";
import { useTranslation } from "react-i18next";
const { useToken } = theme; const { useToken } = theme;
...@@ -60,6 +61,7 @@ const initialPhaseBind: [ ...@@ -60,6 +61,7 @@ const initialPhaseBind: [
]; ];
export const Menu = () => { export const Menu = () => {
const { t: i18n } = useTranslation("Menu");
const { const {
currentPlayer, currentPlayer,
chainSetting, chainSetting,
...@@ -136,13 +138,12 @@ export const Menu = () => { ...@@ -136,13 +138,12 @@ export const Menu = () => {
}, },
}), }),
); );
const surrenderMenuItems: MenuProps["items"] = [ const surrenderMenuItems: MenuProps["items"] = [
{ {
label: "取消", label: i18n("Cancel"),
}, },
{ {
label: "确定", label: i18n("Confirm"),
danger: true, danger: true,
onClick: sendSurrender, onClick: sendSurrender,
}, },
...@@ -184,7 +185,7 @@ export const Menu = () => { ...@@ -184,7 +185,7 @@ export const Menu = () => {
></Button> ></Button>
</Tooltip> </Tooltip>
<DropdownWithTitle <DropdownWithTitle
title="是否投降?" title={ i18n("DoYouSurrunder") }
menu={{ items: surrenderMenuItems }} menu={{ items: surrenderMenuItems }}
> >
<Button icon={<CloseCircleFilled />} type="text"></Button> <Button icon={<CloseCircleFilled />} type="text"></Button>
......
...@@ -4,22 +4,32 @@ import { IconFont } from "@/ui/Shared"; ...@@ -4,22 +4,32 @@ import { IconFont } from "@/ui/Shared";
import CardPosition = ygopro.CardPosition; import CardPosition = ygopro.CardPosition;
const language = localStorage.getItem('language');
const sSet = language === 'en' ? 'Set' : '后场放置';
const summon = language === 'en' ? 'Normal Summon' : '普通召唤';
const spSummon = language === 'en' ? 'Special Summon' : '特殊召唤';
const posChange = language === 'en' ? 'Change Position' : '改变表示形式';
const mSet = language === 'en' ? 'Set' : '前场放置';
const activate = language === 'en' ? 'Activate' : '发动效果';
const attack = language === 'en' ? 'Attack' : '攻击';
export function interactTypeToString(t: InteractType): string { export function interactTypeToString(t: InteractType): string {
switch (t) { switch (t) {
case InteractType.SUMMON: case InteractType.SUMMON:
return "普通召唤"; return summon;
case InteractType.SP_SUMMON: case InteractType.SP_SUMMON:
return "特殊召唤"; return spSummon;
case InteractType.POS_CHANGE: case InteractType.POS_CHANGE:
return "改变表示形式"; return posChange;
case InteractType.MSET: case InteractType.MSET:
return "前场放置"; return mSet;
case InteractType.SSET: case InteractType.SSET:
return "后场放置"; return sSet;
case InteractType.ACTIVATE: case InteractType.ACTIVATE:
return "发动效果"; return activate;
case InteractType.ATTACK: case InteractType.ATTACK:
return "攻击"; return attack;
default: default:
return "未知选项"; return "未知选项";
} }
......
...@@ -160,7 +160,8 @@ ...@@ -160,7 +160,8 @@
"KoishiServer": "Koishi服", "KoishiServer": "Koishi服",
"UltraPreemptiveServer": "超先行服", "UltraPreemptiveServer": "超先行服",
"PlayerNickname": "玩家昵称", "PlayerNickname": "玩家昵称",
"RoomPasswordOptional": "房间密码(可选)" "RoomPasswordOptional": "房间密码(可选)",
"JoinRoom": "加入房间"
}, },
"ReplayModal": { "ReplayModal": {
"SelectReplay": "选择回放", "SelectReplay": "选择回放",
...@@ -172,5 +173,10 @@ ...@@ -172,5 +173,10 @@
"Popover": { "Popover": {
"First": "先手", "First": "先手",
"Second": "后手" "Second": "后手"
},
"Menu": {
"DoYouSurrunder": "是否投降?",
"Cancel": "取消",
"Confirm": "确定"
} }
} }
\ No newline at end of file
...@@ -160,7 +160,8 @@ ...@@ -160,7 +160,8 @@
"KoishiServer": "Koishi Server", "KoishiServer": "Koishi Server",
"UltraPreemptiveServer": "Ultra Preemptive Server", "UltraPreemptiveServer": "Ultra Preemptive Server",
"PlayerNickname": "Player Nickname", "PlayerNickname": "Player Nickname",
"RoomPasswordOptional": "Room Password (optional)" "RoomPasswordOptional": "Room Password (optional)",
"JoinRoom": "Join the Room"
}, },
"ReplayModal": { "ReplayModal": {
"SelectReplay": "Select Replay", "SelectReplay": "Select Replay",
...@@ -172,5 +173,10 @@ ...@@ -172,5 +173,10 @@
"Popover": { "Popover": {
"First": "First", "First": "First",
"Second": "Second" "Second": "Second"
},
"Menu": {
"DoYouSurrunder": "Do you surrender?",
"Cancel": "Cancel",
"Confirm": "Confirm"
} }
} }
\ No newline at end of file
...@@ -29,6 +29,7 @@ const resources = { ...@@ -29,6 +29,7 @@ const resources = {
MatchModal: translationChinese.MatchModal, MatchModal: translationChinese.MatchModal,
ReplayModal: translationChinese.ReplayModal, ReplayModal: translationChinese.ReplayModal,
Popover: translationChinese.Popover, Popover: translationChinese.Popover,
Menu: translationChinese.Menu,
}, },
en: { en: {
Header: translationEnglish.Header, Header: translationEnglish.Header,
...@@ -45,6 +46,7 @@ const resources = { ...@@ -45,6 +46,7 @@ const resources = {
MatchModal: translationEnglish.MatchModal, MatchModal: translationEnglish.MatchModal,
ReplayModal: translationEnglish.ReplayModal, ReplayModal: translationEnglish.ReplayModal,
Popover: translationEnglish.Popover, Popover: translationEnglish.Popover,
Menu: translationEnglish.Menu,
}, },
es: { es: {
Header: translationSpanish.Header, Header: translationSpanish.Header,
......
...@@ -93,7 +93,7 @@ export const MatchModal: React.FC = ({}) => { ...@@ -93,7 +93,7 @@ export const MatchModal: React.FC = ({}) => {
onCancel={() => (matchStore.open = false)} onCancel={() => (matchStore.open = false)}
footer={ footer={
<Button onClick={handleSubmit} loading={confirmLoading}> <Button onClick={handleSubmit} loading={confirmLoading}>
加入房间 {i18n("JoinRoom")}
</Button> </Button>
} }
confirmLoading={confirmLoading} confirmLoading={confirmLoading}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment