Commit 6aafbde0 authored by BBeretta's avatar BBeretta

feat/language-translation (Deck Select, Build Deck, Store)

parent 12916da4
Pipeline #27382 failed with stages
in 7 minutes and 23 seconds
......@@ -13,6 +13,7 @@ import { deckStore, IDeck } from "@/stores";
import { Uploader } from "../Shared";
import styles from "./DeckSelect.module.scss";
import { useTranslation } from "react-i18next";
export const DeckSelect: React.FC<{
decks: readonly { deckName: string }[];
......@@ -24,6 +25,7 @@ export const DeckSelect: React.FC<{
}> = ({ decks, selected, onSelect, onDelete, onDownload, onCopy }) => {
const newDeck = useRef<IDeck[]>([]);
const { modal, message } = App.useApp();
const { t: i18n } = useTranslation("DeckSelect");
/** 创建卡组,直接给一个命名,用户可以手动修改,无需modal打断流程 */
const createNewDeck = async () => {
......@@ -104,17 +106,17 @@ export const DeckSelect: React.FC<{
const items: MenuProps["items"] = [
{
label: "新建卡组",
label: `${i18n("CreateNewDeck")}`,
icon: <PlusOutlined />,
onClick: createNewDeck,
},
{
label: "从本地文件导入",
label: `${i18n("ImportFromLocalFile")}`,
icon: <FileAddOutlined />,
onClick: showUploadModal,
},
{
label: "从剪贴板导入",
label: `${i18n("ImportFromClipboard")}`,
icon: <CopyOutlined />,
onClick: importFromClipboard,
},
......@@ -140,8 +142,8 @@ export const DeckSelect: React.FC<{
onClick={cancelBubble(async () => {
const result = await onCopy(deckName);
result
? message.success("复制成功")
: message.error("复制失败");
? message.success(`${i18n("CopySuccessful")}`)
: message.error(`${i18n("CopyFailed")}`);
})}
/>
<Button
......@@ -182,6 +184,7 @@ const DeckUploader: React.FC<{ onLoaded: (deck: IDeck) => void }> = ({
}) => {
const [uploadState, setUploadState] = useState("");
const { message } = App.useApp();
const { t: i18n } = useTranslation("DeckSelect");
const uploadProps: UploadProps = {
name: "file",
multiple: true,
......@@ -213,8 +216,8 @@ const DeckUploader: React.FC<{ onLoaded: (deck: IDeck) => void }> = ({
return (
<Uploader
{...uploadProps}
text="单击或拖动文件到此区域进行上传"
hint="仅支持后缀名为ydk的卡组文件。"
text={i18n("ClickOrDragFilesHereToUpload")}
hint={i18n("SupportsYdkExtension")}
/>
);
};
......
......@@ -92,10 +92,10 @@ export const Component: React.FC = () => {
);
const { message } = App.useApp();
const { t: i18n } = useTranslation("BuildDeck");
const handleDeckEditorReset = async () => {
editDeckStore.set(await iDeckToEditingDeck(selectedDeck));
message.info("重置成功");
message.info(`${i18n("ResetSuccessful")}`);
};
const handleDeckEditorSave = async () => {
......@@ -103,7 +103,7 @@ export const Component: React.FC = () => {
const result = await deckStore.update(selectedDeck.deckName, tmpIDeck);
if (result) {
setSelectedDeck(tmpIDeck);
message.info("保存成功");
message.info(`${i18n("SaveSuccessful")}`);
editDeckStore.edited = false;
} else {
editDeckStore.set(await iDeckToEditingDeck(selectedDeck));
......
......@@ -7,6 +7,12 @@ import { Type } from "@/ui/Shared/DeckZone";
import { compareCards, type EditingDeck } from "./utils";
const language = localStorage.getItem("language");
const cardTypeNotMatch = language === 'en' ? "The Card Type does not match" : "卡片种类不符合";
const exceedsNumberCardsSameName = language === 'en' ? "Exceeds the number of cards with the same name" : "超过同名卡";
const limitCards = language === 'en' ? 'Limit of cards' : '张的上限';
const exceedsLimit = language === 'en' ? 'Exceeds the limit' : '超过';
const cannotAddTokens = language === 'en' ? 'Cannot add tokens' : '不能添加衍生物';
export const editDeckStore = proxy({
deckName: "",
main: [] as CardMeta[],
......@@ -75,13 +81,13 @@ export const editDeckStore = proxy({
if (isToken(cardType)) {
result = false;
reason = "不能添加衍生物";
reason = cannotAddTokens;
}
const countLimit = type === "main" ? 60 : 15;
if (deckType.length >= countLimit) {
result = false;
reason = `超过 ${countLimit} 张的上限`;
reason = `${exceedsLimit} ${countLimit} ${limitCards}`;
}
if (
......@@ -89,9 +95,8 @@ export const editDeckStore = proxy({
(type === "main" && isExtraDeckCard(cardType))
) {
result = false;
reason = "卡片种类不符合";
reason = cardTypeNotMatch;
}
const max = 3; // 这里无需参考禁卡表
const numOfSameCards =
editDeckStore
......@@ -105,7 +110,7 @@ export const editDeckStore = proxy({
if (numOfSameCards >= max) {
result = false;
reason = `超过同名卡 ${max} 张的上限`;
reason = `${exceedsNumberCardsSameName} ${max} ${limitCards}`;
}
return { result, reason };
......
......@@ -59,7 +59,9 @@
"StarsRanksLevelsLinkFromHighToLow": "星/阶/刻/Link从高到低",
"StarsRanksLevelsLinkFromLowToHigh": "星/阶/刻/Link从低到高",
"PendulumScaleFromHighToLow": "灵摆刻度从高到低",
"PendulumScaleFromLowToHigh": "灵摆刻度从低到高"
"PendulumScaleFromLowToHigh": "灵摆刻度从低到高",
"ResetSuccessful": "重置成功",
"SaveSuccessful": "保存成功"
},
"Filter": {
"CardFilter": "卡片筛选",
......@@ -139,8 +141,14 @@
"RankedMatch": "竞技匹配",
"Versus": "与"
},
"Store": {
"CannotAddTokens": "不能添加衍生物",
"CardTypeDoesNotMatch": "卡片种类不符合"
"DeckSelect": {
"CopySuccessful": "复制成功",
"CopyFailed": "复制失败",
"CreateNewDeck": "新建卡组",
"ImportFromLocalFile": "从本地文件导入",
"ImportFromClipboard": "从剪贴板导入",
"ClickOrDragFilesHereToUpload": "单击或拖动文件到此区域进行上传",
"SupportsYdkExtension": "仅支持后缀名为ydk的卡组文件。",
"UnableToReadClipboardContent": "无法读取剪贴板内容:"
}
}
\ No newline at end of file
......@@ -59,7 +59,9 @@
"StarsRanksLevelsLinkFromHighToLow": "Stars/Ranks/Levels/Link from high to low",
"StarsRanksLevelsLinkFromLowToHigh": "Stars/Ranks/Levels/Link from low to high",
"PendulumScaleFromHighToLow": "Pendulum Scale from high to low",
"PendulumScaleFromLowToHigh": "Pendulum Scale from low to high"
"PendulumScaleFromLowToHigh": "Pendulum Scale from low to high",
"ResetSuccessful": "Reset successful",
"SaveSuccessful": "Save successful"
},
"Filter": {
"CardFilter": "Card Filter",
......@@ -139,8 +141,14 @@
"RankedMatch": "Ranked Match",
"Versus": "vs"
},
"Store": {
"CannotAddTokens": "Cannot add Tokens",
"CardTypeDoesNotMatch": "The card type does not match"
"DeckSelect": {
"CopySuccessful": "Copy successful",
"CopyFailed.": "Copy failed",
"CreateNewDeck": "Create new deck",
"ImportFromLocalFile": "Import from local file",
"ImportFromClipboard": "Import from clipboard",
"ClickOrDragFilesHereToUpload": "Click or drag files here to upload",
"SupportsYdkExtension": "Only supports deck files with the .ydk extension.",
"UnableToReadClipboardContent": "Unable to read clipboard content."
}
}
\ No newline at end of file
......@@ -22,9 +22,9 @@ const resources = {
Filter: translationChinese.Filter,
CardDetails: translationChinese.CardDetails,
WaitRoom: translationChinese.WaitRoom,
Store: translationChinese.Store,
CustomRoomContent: translationChinese.CustomRoomContent,
WatchContent: translationChinese.WatchContent,
DeckSelect: translationChinese.DeckSelect,
},
en: {
Header: translationEnglish.Header,
......@@ -34,9 +34,9 @@ const resources = {
Filter: translationEnglish.Filter,
CardDetails: translationEnglish.CardDetails,
WaitRoom: translationEnglish.WaitRoom,
Store: translationEnglish.Store,
CustomRoomContent: translationEnglish.CustomRoomContent,
WatchContent: translationEnglish.WatchContent
WatchContent: translationEnglish.WatchContent,
DeckSelect: translationEnglish.DeckSelect,
},
es: {
Header: translationSpanish.Header,
......
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