Commit 84966516 authored by BBeretta's avatar BBeretta

feat/language-translation (Prettier fixes)

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