Commit 3ed6bdd4 authored by BBeretta's avatar BBeretta

feat/language-translation (prettier fixes)

parent 5390fb5e
Pipeline #27823 passed with stages
in 9 minutes and 15 seconds
...@@ -69,7 +69,6 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) { ...@@ -69,7 +69,6 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
const info = action.initInfo; const info = action.initInfo;
if (info) { if (info) {
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 ( if (
language === "en" || language === "en" ||
...@@ -82,12 +81,12 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) { ...@@ -82,12 +81,12 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
} else if (language === "ja") { } else if (language === "ja") {
info.releaseDbUrl = info.releaseDbUrl.replace("zh-CN", "ja-JP"); info.releaseDbUrl = info.releaseDbUrl.replace("zh-CN", "ja-JP");
info.preReleaseDbUrl = info.preReleaseDbUrl.replace("zh-CN", "ja-JP"); info.preReleaseDbUrl = info.preReleaseDbUrl.replace("zh-CN", "ja-JP");
} else if (language === "es") {
info.releaseDbUrl = info.releaseDbUrl.replace("zh-CN", "es-ES");
info.preReleaseDbUrl = info.preReleaseDbUrl.replace("zh-CN", "es-ES");
} else if (language === "ko") { } else if (language === "ko") {
info.releaseDbUrl = info.releaseDbUrl.replace("zh-CN", "ko-KR"); info.releaseDbUrl = info.releaseDbUrl.replace("zh-CN", "ko-KR");
info.preReleaseDbUrl = info.preReleaseDbUrl.replace("zh-CN", "ko-KR"); info.preReleaseDbUrl = info.preReleaseDbUrl.replace("zh-CN", "ko-KR");
} else if (language === "es") {
info.releaseDbUrl = info.releaseDbUrl.replace("zh-CN", "es-ES");
info.preReleaseDbUrl = info.preReleaseDbUrl.replace("zh-CN", "es-ES");
} }
const releasePromise = pfetch(info.releaseDbUrl, { const releasePromise = pfetch(info.releaseDbUrl, {
......
...@@ -16,7 +16,7 @@ const DECKERROR_NOTAVAIL = 0x9; ...@@ -16,7 +16,7 @@ const DECKERROR_NOTAVAIL = 0x9;
const language = localStorage.getItem("language"); const language = localStorage.getItem("language");
const mainDeckWarining = const mainDeckWarining =
language != "cn" language !== "cn"
? "The main deck should contain 40-60 cards." ? "The main deck should contain 40-60 cards."
: "主卡组数量应为40-60张"; : "主卡组数量应为40-60张";
......
import { Button, Descriptions, type DescriptionsProps } from "antd"; import { Button, Descriptions, type DescriptionsProps } from "antd";
import classNames from "classnames"; import classNames from "classnames";
import { useEffect, useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { type CardMeta, fetchCard, fetchStrings, Region } from "@/api"; import { type CardMeta, fetchCard, fetchStrings, Region } from "@/api";
import { import {
...@@ -15,7 +16,6 @@ import { ...@@ -15,7 +16,6 @@ import {
import { CardEffectText, IconFont, ScrollableArea, YgoCard } from "@/ui/Shared"; import { CardEffectText, IconFont, ScrollableArea, YgoCard } from "@/ui/Shared";
import styles from "./CardDetail.module.scss"; import styles from "./CardDetail.module.scss";
import { useTranslation } from "react-i18next";
export const CardDetail: React.FC<{ export const CardDetail: React.FC<{
code: number; code: number;
......
...@@ -68,7 +68,7 @@ export const Filter: React.FC<{ ...@@ -68,7 +68,7 @@ export const Filter: React.FC<{
[index]: value, [index]: value,
}, },
})); }));
}; };
return ( return (
<> <>
...@@ -124,7 +124,7 @@ export const Filter: React.FC<{ ...@@ -124,7 +124,7 @@ export const Filter: React.FC<{
{i18n("Confirm")} {i18n("Confirm")}
</Button> </Button>
<Button type="text" onClick={onCancel}> <Button type="text" onClick={onCancel}>
{i18n("Cancel")} {i18n("Cancel")}
</Button> </Button>
</div> </div>
</> </>
......
...@@ -466,7 +466,7 @@ const Search: React.FC = () => { ...@@ -466,7 +466,7 @@ const Search: React.FC = () => {
icon={<SortAscendingOutlined />} icon={<SortAscendingOutlined />}
> >
<span> <span>
{i18n("SortBy")} {i18n("SortBy")}
<span className={styles["search-count"]}> <span className={styles["search-count"]}>
({searchResult.length}) ({searchResult.length})
</span> </span>
......
...@@ -14,8 +14,8 @@ const exceedsNumberCardsSameName = ...@@ -14,8 +14,8 @@ const exceedsNumberCardsSameName =
language !== "cn" language !== "cn"
? "Exceeds the number of cards with the same name" ? "Exceeds the number of cards with the same name"
: "超过同名卡"; : "超过同名卡";
const limitCards = language != "cn" ? "Limit of cards" : "张的上限"; const limitCards = language !== "cn" ? "Limit of cards" : "张的上限";
const exceedsLimit = language != "cn" ? "Exceeds the limit" : "超过"; const exceedsLimit = language !== "cn" ? "Exceeds the limit" : "超过";
const cannotAddTokens = const cannotAddTokens =
language !== "cn" ? "Cannot add tokens" : "不能添加衍生物"; language !== "cn" ? "Cannot add tokens" : "不能添加衍生物";
......
...@@ -16,8 +16,8 @@ const defaultProps = { isOpen: false, positions: [] }; ...@@ -16,8 +16,8 @@ const defaultProps = { isOpen: false, positions: [] };
const localStore = proxy<PositionModalProps>(defaultProps); const localStore = proxy<PositionModalProps>(defaultProps);
const language = localStorage.getItem('language'); const language = localStorage.getItem("language");
const title = language != 'cn' ? 'Please select a position' : '请选择表示形式'; const title = language != "cn" ? "Please select a position" : "请选择表示形式";
export const PositionModal = () => { export const PositionModal = () => {
const { isOpen, positions } = useSnapshot(localStore); const { isOpen, positions } = useSnapshot(localStore);
...@@ -25,7 +25,6 @@ export const PositionModal = () => { ...@@ -25,7 +25,6 @@ export const PositionModal = () => {
undefined, undefined,
); );
return ( return (
<NeosModal <NeosModal
title={title} title={title}
...@@ -65,10 +64,10 @@ export const PositionModal = () => { ...@@ -65,10 +64,10 @@ export const PositionModal = () => {
}; };
function cardPosition(position: ygopro.CardPosition): string { function cardPosition(position: ygopro.CardPosition): string {
const faceUpAtk = language != 'cn' ? 'Face-Up Attack' : "正面攻击形式"; const faceUpAtk = language !== "cn" ? "Face-Up Attack" : "正面攻击形式";
const faceUpDef = language != 'cn' ? 'Face-Up Defense' : "正面防守形式"; const faceUpDef = language !== "cn" ? "Face-Up Defense" : "正面防守形式";
const faceDownAtk = language != 'cn' ? 'Face-Down Attack' : "背面攻击形式"; const faceDownAtk = language !== "cn" ? "Face-Down Attack" : "背面攻击形式";
const faceDownDef = language != 'cn' ? 'Face-Down Defense' : "背面防守形式"; const faceDownDef = language !== "cn" ? "Face-Down Defense" : "背面防守形式";
switch (position) { switch (position) {
case ygopro.CardPosition.FACEUP_ATTACK: { case ygopro.CardPosition.FACEUP_ATTACK: {
......
...@@ -110,7 +110,9 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -110,7 +110,9 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
<> <>
<span>{preHintMsg}</span> <span>{preHintMsg}</span>
<span>{selectHintMsg}</span> <span>{selectHintMsg}</span>
<span>({i18n("PleaseSelect")} {minMaxText} {i18n("Cards")})</span> <span>
({i18n("PleaseSelect")} {minMaxText} {i18n("Cards")})
</span>
<span>{single ? i18n("SelectOneCardAtTime") : ""}</span> <span>{single ? i18n("SelectOneCardAtTime") : ""}</span>
</> </>
} // TODO: 这里可以再细化一些 } // TODO: 这里可以再细化一些
......
...@@ -140,9 +140,9 @@ export const Menu = () => { ...@@ -140,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],
......
...@@ -4,16 +4,16 @@ import { IconFont } from "@/ui/Shared"; ...@@ -4,16 +4,16 @@ import { IconFont } from "@/ui/Shared";
import CardPosition = ygopro.CardPosition; import CardPosition = ygopro.CardPosition;
const language = localStorage.getItem('language'); const language = localStorage.getItem("language");
export function interactTypeToString(t: InteractType): string { export function interactTypeToString(t: InteractType): string {
const sSet = language != 'cn' ? 'Set' : '后场放置'; const sSet = language !== "cn" ? "Set" : "后场放置";
const summon = language != 'cn' ? 'Normal Summon' : '普通召唤'; const summon = language !== "cn" ? "Normal Summon" : "普通召唤";
const spSummon = language != 'cn' ? 'Special Summon' : '特殊召唤'; const spSummon = language !== "cn" ? "Special Summon" : "特殊召唤";
const posChange = language != 'cn' ? 'Change Position' : '改变表示形式'; const posChange = language !== "cn" ? "Change Position" : "改变表示形式";
const mSet = language != 'cn' ? 'Set' : '前场放置'; const mSet = language !== "cn" ? "Set" : "前场放置";
const activate = language != 'cn' ? 'Activate' : '发动效果'; const activate = language !== "cn" ? "Activate" : "发动效果";
const attack = language != 'cn' ? 'Attack' : '攻击'; const attack = language !== "cn" ? "Attack" : "攻击";
switch (t) { switch (t) {
case InteractType.SUMMON: case InteractType.SUMMON:
......
...@@ -2,6 +2,7 @@ import { CopyOutlined, KeyOutlined } from "@ant-design/icons"; ...@@ -2,6 +2,7 @@ import { CopyOutlined, KeyOutlined } from "@ant-design/icons";
import type { CheckboxProps } from "antd"; import type { CheckboxProps } from "antd";
import { App, Button, Checkbox, Input } from "antd"; import { App, Button, Checkbox, Input } from "antd";
import React, { ChangeEvent, useEffect } from "react"; import React, { ChangeEvent, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { defaultOptions, getPrivateRoomID, Options } from "@/api"; import { defaultOptions, getPrivateRoomID, Options } from "@/api";
...@@ -9,7 +10,6 @@ import { accountStore } from "@/stores"; ...@@ -9,7 +10,6 @@ import { accountStore } from "@/stores";
import { Select } from "@/ui/Shared"; import { Select } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useTranslation } from "react-i18next";
interface CustomRoomProps { interface CustomRoomProps {
options: Options; options: Options;
...@@ -205,10 +205,10 @@ export const CustomRoomFooter: React.FC<{ ...@@ -205,10 +205,10 @@ export const CustomRoomFooter: React.FC<{
return ( return (
<div className={styles.footer}> <div className={styles.footer}>
<Button className={styles.btn} onClick={onCreateRoom}> <Button className={styles.btn} onClick={onCreateRoom}>
{i18n("CreatePrivateRoom")} {i18n("CreatePrivateRoom")}
</Button> </Button>
<Button className={styles.btn} onClick={onJoinRoom}> <Button className={styles.btn} onClick={onJoinRoom}>
{i18n("JoinPrivateRoom")} {i18n("JoinPrivateRoom")}
</Button> </Button>
</div> </div>
); );
......
...@@ -71,7 +71,8 @@ export function getCardImgUrl(code: number, back = false) { ...@@ -71,7 +71,8 @@ export function getCardImgUrl(code: number, back = false) {
language === "en" || language === "en" ||
language === "br" || language === "br" ||
language === "pt" || language === "pt" ||
language === "fr" language === "fr" ||
language === "es"
) { ) {
NeosConfig.releaseImgUrl = NeosConfig.releaseImgUrl.replace( NeosConfig.releaseImgUrl = NeosConfig.releaseImgUrl.replace(
"zh-CN", "zh-CN",
......
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