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