Commit 84966516 authored by BBeretta's avatar BBeretta

feat/language-translation (Prettier fixes)

parent 8f1aa9a7
......@@ -29,7 +29,6 @@ export async function initStrings() {
break;
}
const strings = await (await fetch(stringsUrl)).text();
const lineIter = strings.split("\n");
......
......@@ -13,70 +13,78 @@ type Language = "en" | "br" | "pt" | "fr" | "ja" | "ko" | "es" | "cn";
// Define the structure for the messages (I18N)
const messages: Record<
Language,
{ cardTypeNotMatch: string; exceedsNumberCardsSameName: string, limitCards: string, exceedsLimit: string, cannotAddTokens: string }
{
cardTypeNotMatch: string;
exceedsNumberCardsSameName: string;
limitCards: string;
exceedsLimit: string;
cannotAddTokens: string;
}
> = {
en: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "The number of Extra Deck should be 0-15",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
br: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "The number of Extra Deck should be 0-15",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
pt: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "The number of Extra Deck should be 0-15",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
fr: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "The number of Extra Deck should be 0-15",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
ja: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "The number of Extra Deck should be 0-15",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
ko: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "The number of Extra Deck should be 0-15",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
es: {
cardTypeNotMatch: "The Card Type does not match",
exceedsNumberCardsSameName: "Exceeds the number of cards with the same name",
exceedsNumberCardsSameName:
"Exceeds the number of cards with the same name",
limitCards: "Limit of cards",
exceedsLimit: "Exceeds the limit",
cannotAddTokens: "Cannot add tokens"
cannotAddTokens: "Cannot add tokens",
},
cn: {
cardTypeNotMatch: "卡片种类不符合",
exceedsNumberCardsSameName: "超过同名卡",
limitCards: "张的上限",
exceedsLimit: "超过",
cannotAddTokens: "不能添加衍生物"
cannotAddTokens: "不能添加衍生物",
},
};
// Get the language from localStorage or default to 'cn' (I18N)
const language = (localStorage.getItem("language") || "cn") as Language;
const cardTypeNotMatch = messages[language].cardTypeNotMatch;
const exceedsNumberCardsSameName = messages[language].exceedsNumberCardsSameName;
const exceedsNumberCardsSameName =
messages[language].exceedsNumberCardsSameName;
const limitCards = messages[language].limitCards;
const exceedsLimit = messages[language].exceedsLimit;
const cannotAddTokens = messages[language].cannotAddTokens;
......
......@@ -19,7 +19,7 @@ const localStore = proxy<PositionModalProps>(defaultProps);
// Define a type for translations with an index signature (I18N)
interface Translations {
[key: string]: {
Title: string,
Title: string;
FACEUP_ATTACK: string;
FACEUP_DEFENSE: string;
FACEDOWN_ATTACK: string;
......@@ -90,9 +90,6 @@ const translations: Translations = {
},
};
// // Define translations for different languages (I18N)
// const title = language !== "cn" ? "Please select a position" : "请选择表示形式";
// const test = translations[language].Title
export const PositionModal = () => {
const { isOpen, positions } = useSnapshot(localStore);
const [selected, setSelected] = useState<ygopro.CardPosition | undefined>(
......@@ -143,13 +140,13 @@ function cardPosition(position: ygopro.CardPosition): string {
switch (position) {
case ygopro.CardPosition.FACEUP_ATTACK: {
return messages.FACEUP_ATTACK;;
return messages.FACEUP_ATTACK;
}
case ygopro.CardPosition.FACEUP_DEFENSE: {
return messages.FACEUP_DEFENSE;
}
case ygopro.CardPosition.FACEDOWN_ATTACK: {
return messages.FACEDOWN_ATTACK;;
return messages.FACEDOWN_ATTACK;
}
case ygopro.CardPosition.FACEDOWN_DEFENSE: {
return messages.FACEDOWN_DEFENSE;
......
......@@ -47,7 +47,17 @@ type Language = "en" | "br" | "pt" | "fr" | "ja" | "ko" | "es" | "cn";
const messages: Record<
Language,
{
drawPhase: string; standbyPhase: string, mainPhase1: string, battlePhase: string, battleStart: string, battleStep: string, damage: string, damageCalc: string, mainPhase2: string, endPhase: string, unknown: string
drawPhase: string;
standbyPhase: string;
mainPhase1: string;
battlePhase: string;
battleStart: string;
battleStep: string;
damage: string;
damageCalc: string;
mainPhase2: string;
endPhase: string;
unknown: string;
}
> = {
en: {
......@@ -61,7 +71,7 @@ const messages: Record<
damageCalc: "Damage Step (Damage Calculation)",
mainPhase2: "Main Phase 2",
endPhase: "End Phase",
unknown: "Unknown"
unknown: "Unknown",
},
br: {
drawPhase: "Compra",
......@@ -74,7 +84,7 @@ const messages: Record<
damageCalc: "Fase de Dano (Cálculo de Dano)",
mainPhase2: "Fase Principal 2",
endPhase: "Fase Final",
unknown: "Desconhecido"
unknown: "Desconhecido",
},
pt: {
drawPhase: "Compra",
......@@ -87,7 +97,7 @@ const messages: Record<
damageCalc: "Fase de Dano (Cálculo de Dano)",
mainPhase2: "Fase Principal 2",
endPhase: "Fase Final",
unknown: "Desconhecido"
unknown: "Desconhecido",
},
fr: {
drawPhase: "Pioche",
......@@ -100,7 +110,7 @@ const messages: Record<
damageCalc: "Étape de Dégâts (Calcul des Dégâts)",
mainPhase2: "Phase Principale 2",
endPhase: "Phase Finale",
unknown: "Inconnu"
unknown: "Inconnu",
},
ja: {
drawPhase: "ドロー",
......@@ -113,7 +123,7 @@ const messages: Record<
damageCalc: "ダメージステップ(ダメージ計算)",
mainPhase2: "メインフェイズ 2",
endPhase: "エンドフェイズ",
unknown: "未知"
unknown: "未知",
},
ko: {
drawPhase: "드로우",
......@@ -126,7 +136,7 @@ const messages: Record<
damageCalc: "데미지 스텝 (데미지 계산)",
mainPhase2: "메인 페이즈 2",
endPhase: "엔드 페이즈",
unknown: "알 수 없음"
unknown: "알 수 없음",
},
es: {
drawPhase: "Robo",
......@@ -139,7 +149,7 @@ const messages: Record<
damageCalc: "Paso de Daño (Cálculo de Daño)",
mainPhase2: "Fase Principal 2",
endPhase: "Fase Final",
unknown: "Desconocido"
unknown: "Desconocido",
},
cn: {
drawPhase: "抽卡阶段",
......@@ -190,7 +200,7 @@ const initialPhaseBind: [
[PhaseType.MAIN2, mainPhase2, 2, true, false],
[PhaseType.END, endPhase, 7, true, false],
[PhaseType.UNKNOWN, unknown, -1, false, true],
];
];
export const Menu = () => {
const { t: i18n } = useTranslation("Menu");
......
......@@ -11,7 +11,13 @@ type Language = "en" | "br" | "pt" | "fr" | "ja" | "ko" | "es" | "cn";
const messages: Record<
Language,
{
sSet: string; summon: string, spSummon: string, posChange: string, mSet: string, activate: string, attack: string
sSet: string;
summon: string;
spSummon: string;
posChange: string;
mSet: string;
activate: string;
attack: string;
}
> = {
en: {
......@@ -21,7 +27,7 @@ const messages: Record<
posChange: "Change Position",
mSet: "Set",
activate: "Activate",
attack: "Attack"
attack: "Attack",
},
br: {
sSet: "Setar",
......@@ -30,7 +36,7 @@ const messages: Record<
posChange: "Mudar Posição",
mSet: "Setar",
activate: "Ativar",
attack: "Atacar"
attack: "Atacar",
},
pt: {
sSet: "Setar",
......@@ -39,7 +45,7 @@ const messages: Record<
posChange: "Mudar Posição",
mSet: "Setar",
activate: "Ativar",
attack: "Atacar"
attack: "Atacar",
},
fr: {
sSet: "Poser",
......@@ -48,7 +54,7 @@ const messages: Record<
posChange: "Changer de Position",
mSet: "Poser",
activate: "Activer",
attack: "Attaquer"
attack: "Attaquer",
},
ja: {
sSet: "セット",
......@@ -57,7 +63,7 @@ const messages: Record<
posChange: "表示形式変更",
mSet: "セット",
activate: "発動",
attack: "攻撃"
attack: "攻撃",
},
ko: {
sSet: "세트",
......@@ -66,7 +72,7 @@ const messages: Record<
posChange: "포지션 변경",
mSet: "세트",
activate: "발동",
attack: "공격"
attack: "공격",
},
es: {
sSet: "Colocar",
......@@ -75,7 +81,7 @@ const messages: Record<
posChange: "Cambiar Posición",
mSet: "Colocar",
activate: "Activar",
attack: "Atacar"
attack: "Atacar",
},
cn: {
sSet: "后场放置",
......
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