Commit 5390fb5e authored by BBeretta's avatar BBeretta

feat/language-translation (prettier fixes)

parent a2d18086
Pipeline #27822 failed with stages
in 7 minutes and 13 seconds
...@@ -8,17 +8,19 @@ export const DESCRIPTION_LIMIT = 10000; ...@@ -8,17 +8,19 @@ export const DESCRIPTION_LIMIT = 10000;
export async function initStrings() { export async function initStrings() {
const language = localStorage.getItem("language") || "cn"; const language = localStorage.getItem("language") || "cn";
//It currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN //It currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN
if (language === "en" || language === "br" || language === "pt" || language === "fr") { if (
language === "en" ||
language === "br" ||
language === "pt" ||
language === "fr"
) {
stringsUrl = stringsUrl.replace("zh-CN", "en-US"); stringsUrl = stringsUrl.replace("zh-CN", "en-US");
} } else if (language === "ja") {
else if (language === "ja") {
stringsUrl = stringsUrl.replace("zh-CN", "ja-JP"); stringsUrl = stringsUrl.replace("zh-CN", "ja-JP");
} } else if (language === "es") {
else if (language === "es") {
stringsUrl = stringsUrl.replace("zh-CN", "es-ES"); stringsUrl = stringsUrl.replace("zh-CN", "es-ES");
} } else if (language === "ko") {
else if (language === "ko") {
stringsUrl = stringsUrl.replace("zh-CN", "ko-KR"); stringsUrl = stringsUrl.replace("zh-CN", "ko-KR");
} }
......
...@@ -14,8 +14,11 @@ const DECKERROR_EXTRACOUNT = 0x7; ...@@ -14,8 +14,11 @@ 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 language = localStorage.getItem("language");
const mainDeckWarining = language != 'cn' ? 'The main deck should contain 40-60 cards.' : '主卡组数量应为40-60张'; const mainDeckWarining =
language != "cn"
? "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;
......
...@@ -7,13 +7,13 @@ import { ...@@ -7,13 +7,13 @@ import {
} from "@ant-design/icons"; } from "@ant-design/icons";
import { App, Button, Dropdown, MenuProps, UploadProps } from "antd"; import { App, Button, Dropdown, MenuProps, UploadProps } from "antd";
import React, { useRef, useState } from "react"; import React, { useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import YGOProDeck from "ygopro-deck-encode"; import YGOProDeck from "ygopro-deck-encode";
import { deckStore, IDeck } from "@/stores"; import { deckStore, IDeck } from "@/stores";
import { Uploader } from "../Shared"; import { Uploader } from "../Shared";
import styles from "./DeckSelect.module.scss"; import styles from "./DeckSelect.module.scss";
import { useTranslation } from "react-i18next";
export const DeckSelect: React.FC<{ export const DeckSelect: React.FC<{
decks: readonly { deckName: string }[]; decks: readonly { deckName: string }[];
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
Tooltip, Tooltip,
} from "antd"; } from "antd";
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next";
import { fetchStrings, Region } from "@/api"; import { fetchStrings, Region } from "@/api";
import { import {
...@@ -17,7 +18,6 @@ import { ...@@ -17,7 +18,6 @@ import {
import { FtsConditions } from "@/middleware/sqlite/fts"; import { FtsConditions } from "@/middleware/sqlite/fts";
import styles from "./Filter.module.scss"; import styles from "./Filter.module.scss";
import { useTranslation } from "react-i18next";
const levels = Array.from({ length: 12 }, (_, index) => ({ const levels = Array.from({ length: 12 }, (_, index) => ({
value: index + 1, value: index + 1,
......
...@@ -27,6 +27,7 @@ import { HTML5toTouch } from "rdndmb-html5-to-touch"; ...@@ -27,6 +27,7 @@ import { HTML5toTouch } from "rdndmb-html5-to-touch";
import { memo, useCallback, useEffect, useRef, useState } from "react"; import { memo, useCallback, useEffect, useRef, useState } from "react";
import { useDrop } from "react-dnd"; import { useDrop } from "react-dnd";
import { DndProvider } from "react-dnd-multi-backend"; import { DndProvider } from "react-dnd-multi-backend";
import { useTranslation } from "react-i18next";
import { LoaderFunction } from "react-router-dom"; import { LoaderFunction } from "react-router-dom";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { subscribeKey } from "valtio/utils"; import { subscribeKey } from "valtio/utils";
...@@ -57,7 +58,6 @@ import { ...@@ -57,7 +58,6 @@ import {
editingDeckToIDeck, editingDeckToIDeck,
iDeckToEditingDeck, iDeckToEditingDeck,
} from "./utils"; } from "./utils";
import { useTranslation } from "react-i18next";
export const loader: LoaderFunction = async () => { export const loader: LoaderFunction = async () => {
// 必须先加载卡组,不然页面会崩溃 // 必须先加载卡组,不然页面会崩溃
......
...@@ -8,11 +8,16 @@ import { Type } from "@/ui/Shared/DeckZone"; ...@@ -8,11 +8,16 @@ import { Type } from "@/ui/Shared/DeckZone";
import { compareCards, type EditingDeck } from "./utils"; import { compareCards, type EditingDeck } from "./utils";
const language = localStorage.getItem("language"); const language = localStorage.getItem("language");
const cardTypeNotMatch = language != 'cn' ? "The Card Type does not match" : "卡片种类不符合"; const cardTypeNotMatch =
const exceedsNumberCardsSameName = language != 'cn' ? "Exceeds the number of cards with the same name" : "超过同名卡"; language !== "cn" ? "The Card Type does not match" : "卡片种类不符合";
const limitCards = language != 'cn' ? 'Limit of cards' : '张的上限'; const exceedsNumberCardsSameName =
const exceedsLimit = language != 'cn' ? 'Exceeds the limit' : '超过'; language !== "cn"
const cannotAddTokens = language != 'cn' ? 'Cannot add tokens' : '不能添加衍生物'; ? "Exceeds the number of cards with the same name"
: "超过同名卡";
const limitCards = language != "cn" ? "Limit of cards" : "张的上限";
const exceedsLimit = language != "cn" ? "Exceeds the limit" : "超过";
const cannotAddTokens =
language !== "cn" ? "Cannot add tokens" : "不能添加衍生物";
export const editDeckStore = proxy({ export const editDeckStore = proxy({
deckName: "", deckName: "",
......
...@@ -7,7 +7,6 @@ import { proxy, useSnapshot } from "valtio"; ...@@ -7,7 +7,6 @@ import { proxy, useSnapshot } from "valtio";
import { sendSelectPositionResponse, ygopro } from "@/api"; import { sendSelectPositionResponse, ygopro } from "@/api";
import { NeosModal } from "../NeosModal"; import { NeosModal } from "../NeosModal";
import { useTranslation } from "react-i18next";
interface PositionModalProps { interface PositionModalProps {
isOpen: boolean; isOpen: boolean;
......
...@@ -2,6 +2,7 @@ import { CheckCard } from "@ant-design/pro-components"; ...@@ -2,6 +2,7 @@ import { CheckCard } from "@ant-design/pro-components";
import { Button, Card, Segmented, Space, Tooltip } from "antd"; import { Button, Card, Segmented, Space, Tooltip } from "antd";
import classnames from "classnames"; import classnames from "classnames";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio"; import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio";
import { type CardMeta, Region, type ygopro } from "@/api"; import { type CardMeta, Region, type ygopro } from "@/api";
...@@ -13,7 +14,6 @@ import { groupBy } from "../../utils"; ...@@ -13,7 +14,6 @@ import { groupBy } from "../../utils";
import { showCardModal } from "../CardModal"; import { showCardModal } from "../CardModal";
import { NeosModal } from "../NeosModal"; import { NeosModal } from "../NeosModal";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useTranslation } from "react-i18next";
export interface SelectCardsModalProps { export interface SelectCardsModalProps {
isOpen: boolean; isOpen: boolean;
......
import { DownOutlined } from "@ant-design/icons"; import { DownOutlined } from "@ant-design/icons";
import { Button, Drawer, Input } from "antd"; import { Button, Drawer, Input } from "antd";
import React from "react"; import React from "react";
import { useTranslation } from "react-i18next";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { IconFont, ScrollableArea, useChat } from "@/ui/Shared"; import { IconFont, ScrollableArea, useChat } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useTranslation } from "react-i18next";
const store = proxy({ open: false }); const store = proxy({ open: false });
......
...@@ -31,26 +31,30 @@ import { IconFont } from "@/ui/Shared"; ...@@ -31,26 +31,30 @@ import { IconFont } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType; import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
import { useTranslation } from "react-i18next";
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;
const FINISH_CANCEL_RESPONSE = -1; const FINISH_CANCEL_RESPONSE = -1;
const language = localStorage.getItem('language'); const language = localStorage.getItem("language");
const drawPhase = language != 'cn' ? 'Draw' : '抽卡阶段'; const drawPhase = language !== "cn" ? "Draw" : "抽卡阶段";
const standbyPhase = language != 'cn' ? 'Standhy Phase' : '准备阶段'; const standbyPhase = language !== "cn" ? "Standhy Phase" : "准备阶段";
const mainPhase1 = language != 'cn' ? 'Main Phase 1' : '主要阶段 1'; const mainPhase1 = language !== "cn" ? "Main Phase 1" : "主要阶段 1";
const battlePhase = language != 'cn' ? 'Battle Phase' : '战斗阶段'; const battlePhase = language !== "cn" ? "Battle Phase" : "战斗阶段";
const battleStart = language != 'cn' ? 'Battle Start' : '战斗开始'; const battleStart = language !== "cn" ? "Battle Start" : "战斗开始";
const battleStep = language != 'cn' ? 'Battle Step' : '战斗步骤'; const battleStep = language !== "cn" ? "Battle Step" : "战斗步骤";
const damage = language != 'cn' ? 'Damage Step' : '伤害步骤'; const damage = language !== "cn" ? "Damage Step" : "伤害步骤";
const damageCalc = language != 'cn' ? 'Damage Step (Damage Calculation)' : '伤害步骤(伤害计算)'; const damageCalc =
const mainPhase2 = language != 'cn' ? 'Main Phase 2' : '主要阶段 2'; language !== "cn"
const endPhase = language != 'cn' ? 'End Phase' : '结束阶段'; ? "Damage Step (Damage Calculation)"
const unknown = language != 'cn' ? 'Unknown' : '未知阶段'; : "伤害步骤(伤害计算)";
const mainPhase2 = language !== "cn" ? "Main Phase 2" : "主要阶段 2";
const endPhase = language !== "cn" ? "End Phase" : "结束阶段";
const unknown = language !== "cn" ? "Unknown" : "未知阶段";
// PhaseType, 中文, response, 是否显示,是否禁用 // PhaseType, 中文, response, 是否显示,是否禁用
const initialPhaseBind: [ const initialPhaseBind: [
...@@ -136,9 +140,9 @@ export const Menu = () => { ...@@ -136,9 +140,9 @@ export const Menu = () => {
setPhaseSwitchItems(newPhaseSwitchItems); setPhaseSwitchItems(newPhaseSwitchItems);
}, [phaseBind]); }, [phaseBind]);
const allChain = language != 'cn' ? 'All Chain' : ''; const allChain = language != "cn" ? "All Chain" : "";
const ignoreChain = language != 'cn' ? 'Ignore Chain' : ''; const ignoreChain = language != "cn" ? "Ignore Chain" : "";
const smartChain = language != 'cn' ? 'Smart Chain' : ''; const smartChain = language != "cn" ? "Smart Chain" : "";
const chainSettingTexts = [ const chainSettingTexts = [
[ChainSetting.CHAIN_ALL, allChain], [ChainSetting.CHAIN_ALL, allChain],
...@@ -202,7 +206,7 @@ export const Menu = () => { ...@@ -202,7 +206,7 @@ export const Menu = () => {
></Button> ></Button>
</Tooltip> </Tooltip>
<DropdownWithTitle <DropdownWithTitle
title={ i18n("DoYouSurrunder") } title={i18n("DoYouSurrunder")}
menu={{ items: surrenderMenuItems }} menu={{ items: surrenderMenuItems }}
> >
<Button icon={<CloseCircleFilled />} type="text"></Button> <Button icon={<CloseCircleFilled />} type="text"></Button>
......
...@@ -2,6 +2,7 @@ import React, { useEffect } from "react"; ...@@ -2,6 +2,7 @@ import React, { useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Select } from "@/ui/Shared"; import { Select } from "@/ui/Shared";
import { useI18N } from "../I18NContext"; import { useI18N } from "../I18NContext";
export const I18NSelector: React.FC = () => { export const I18NSelector: React.FC = () => {
......
import { App, Button, Input, Modal } from "antd"; import { App, Button, Input, Modal } from "antd";
import React, { ChangeEvent, useEffect, useState } from "react"; import React, { ChangeEvent, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
...@@ -9,7 +10,6 @@ import { Select } from "@/ui/Shared"; ...@@ -9,7 +10,6 @@ import { Select } from "@/ui/Shared";
import { connectSrvpro } from "../util"; import { connectSrvpro } from "../util";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useTranslation } from "react-i18next";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
const serverConfig = NeosConfig.servers; const serverConfig = NeosConfig.servers;
......
import { Button, message, Modal, UploadProps } from "antd"; import { Button, message, Modal, UploadProps } from "antd";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
...@@ -7,7 +8,6 @@ import { replayStore } from "@/stores"; ...@@ -7,7 +8,6 @@ import { replayStore } from "@/stores";
import { Uploader } from "../../Shared"; import { Uploader } from "../../Shared";
import { connectSrvpro } from "../util"; import { connectSrvpro } from "../util";
import { useTranslation } from "react-i18next";
const localStore = proxy({ const localStore = proxy({
open: false, open: false,
......
...@@ -2,6 +2,7 @@ import { SearchOutlined } from "@ant-design/icons"; ...@@ -2,6 +2,7 @@ import { SearchOutlined } from "@ant-design/icons";
import { App, Avatar, Button, Divider, Empty, Input } from "antd"; import { App, Avatar, Button, Divider, Empty, Input } from "antd";
import classNames from "classnames"; import classNames from "classnames";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import useWebSocket, { ReadyState } from "react-use-websocket"; import useWebSocket, { ReadyState } from "react-use-websocket";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
...@@ -10,7 +11,6 @@ import { useConfig } from "@/config"; ...@@ -10,7 +11,6 @@ import { useConfig } from "@/config";
import { ScrollableArea } from "../../Shared"; import { ScrollableArea } from "../../Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useTranslation } from "react-i18next";
const { athleticWatchUrl } = useConfig(); const { athleticWatchUrl } = useConfig();
...@@ -130,8 +130,9 @@ export const WatchContent: React.FC = () => { ...@@ -130,8 +130,9 @@ export const WatchContent: React.FC = () => {
<Avatar src={room.users?.at(1)?.avatar} /> <Avatar src={room.users?.at(1)?.avatar} />
</div> </div>
<div className={styles.title}> <div className={styles.title}>
{`${room.users?.at(0)?.username}` + ` ${i18n("Versus")} ` + `${room.users?.at(1) {`${room.users?.at(0)?.username}` +
?.username} 的决斗`} ` ${i18n("Versus")} ` +
`${room.users?.at(1)?.username} 的决斗`}
</div> </div>
<div className={styles.mode}>{i18n("RankedMatch")}</div> <div className={styles.mode}>{i18n("RankedMatch")}</div>
</div> </div>
......
import { Button, Input } from "antd"; import { Button, Input } from "antd";
import { useTranslation } from "react-i18next";
import { IconFont, ScrollableArea, useChat } from "@/ui/Shared"; import { IconFont, ScrollableArea, useChat } from "@/ui/Shared";
import styles from "./Chat.module.scss"; import styles from "./Chat.module.scss";
import { useTranslation } from "react-i18next";
interface ChatItem { interface ChatItem {
name: string; name: string;
......
import { Button, Popover, Space } from "antd"; import { Button, Popover, Space } from "antd";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { eventbus, Task } from "@/infra"; import { eventbus, Task } from "@/infra";
import { IconFont } from "../Shared"; import { IconFont } from "../Shared";
import { useTranslation } from "react-i18next";
export enum Mora { export enum Mora {
Scissors = "scissors", Scissors = "scissors",
...@@ -40,8 +40,8 @@ export const MoraPopover: React.FC< ...@@ -40,8 +40,8 @@ export const MoraPopover: React.FC<
const map = { const map = {
[Mora.Rock]: i18n("Rock"), [Mora.Rock]: i18n("Rock"),
[Mora.Scissors]: i18n("Scissors"), [Mora.Scissors]: i18n("Scissors"),
[Mora.Paper]: i18n("Paper") [Mora.Paper]: i18n("Paper"),
}; };
return ( return (
......
...@@ -17,6 +17,7 @@ import SelfType = ygopro.StocTypeChange.SelfType; ...@@ -17,6 +17,7 @@ import SelfType = ygopro.StocTypeChange.SelfType;
import { App, Avatar, Button, Skeleton, Space } from "antd"; import { App, Avatar, Button, Skeleton, Space } from "antd";
import classNames from "classnames"; import classNames from "classnames";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
...@@ -36,7 +37,6 @@ import { Background, IconFont, Select, SpecialButton } from "@/ui/Shared"; ...@@ -36,7 +37,6 @@ import { Background, IconFont, Select, SpecialButton } from "@/ui/Shared";
import { Chat } from "./Chat"; import { Chat } from "./Chat";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { Mora, MoraPopover, Tp, TpPopover } from "./Popover"; import { Mora, MoraPopover, Tp, TpPopover } from "./Popover";
import { useTranslation } from "react-i18next";
const NeosConfig = useConfig(); const NeosConfig = useConfig();
...@@ -262,7 +262,7 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({ ...@@ -262,7 +262,7 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
return ( return (
<Space> <Space>
<Select <Select
title={ i18n("Deck") } title={i18n("Deck")}
showSearch showSearch
style={{ width: "15.6rem" }} style={{ width: "15.6rem" }}
defaultValue={snapDeck.decks[0].deckName} defaultValue={snapDeck.decks[0].deckName}
...@@ -286,7 +286,9 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({ ...@@ -286,7 +286,9 @@ const Controller: React.FC<{ onDeckChange: (deckName: string) => void }> = ({
} }
}} }}
> >
{snapRoom.selfType === SelfType.OBSERVER ? i18n("JoinDuelist") : i18n("JoinSpectator") } {snapRoom.selfType === SelfType.OBSERVER
? i18n("JoinDuelist")
: i18n("JoinSpectator")}
{!!snapRoom.observerCount && ( {!!snapRoom.observerCount && (
<Avatar size="small" style={{ marginLeft: 8 }}> <Avatar size="small" style={{ marginLeft: 8 }}>
{snapRoom.observerCount} {snapRoom.observerCount}
...@@ -311,7 +313,9 @@ const SideButtons: React.FC<{ ...@@ -311,7 +313,9 @@ const SideButtons: React.FC<{
icon={ icon={
<span className={styles["btn-icon"]}> <span className={styles["btn-icon"]}>
<IconFont type="icon-exit" size={17} /> <IconFont type="icon-exit" size={17} />
<span className={styles["btn-text"]}>&nbsp;&nbsp;{i18n("LeaveRoom")}</span> <span className={styles["btn-text"]}>
&nbsp;&nbsp;{i18n("LeaveRoom")}
</span>
</span> </span>
} }
onClick={() => { onClick={() => {
...@@ -329,7 +333,8 @@ const SideButtons: React.FC<{ ...@@ -329,7 +333,8 @@ const SideButtons: React.FC<{
<span className={styles["btn-icon"]}> <span className={styles["btn-icon"]}>
<IconFont type="icon-side-bar-fill" size={16} /> <IconFont type="icon-side-bar-fill" size={16} />
<span className={styles["btn-text"]}> <span className={styles["btn-text"]}>
&nbsp;&nbsp;{collapsed ? i18n("Expand") : i18n("Collapse")} {i18n("Sidebar")} &nbsp;&nbsp;{collapsed ? i18n("Expand") : i18n("Collapse")}{" "}
{i18n("Sidebar")}
</span> </span>
</span> </span>
} }
......
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