From dc575d44a311ecceb581320468478d7870ea891b Mon Sep 17 00:00:00 2001 From: Edralo Date: Wed, 24 Apr 2024 22:10:03 +0200 Subject: [PATCH] Implement localisation for pokemon stats & add french locale --- src/data/pokemon-stat.ts | 14 ++++++++------ src/locales/en/pokemon-stat.ts | 16 ++++++++++++++++ src/locales/es/pokemon-stat.ts | 16 ++++++++++++++++ src/locales/fr/pokemon-stat.ts | 16 ++++++++++++++++ src/locales/it/pokemon-stat.ts | 16 ++++++++++++++++ src/plugins/i18n.ts | 10 ++++++++++ 6 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 src/locales/en/pokemon-stat.ts create mode 100644 src/locales/es/pokemon-stat.ts create mode 100644 src/locales/fr/pokemon-stat.ts create mode 100644 src/locales/it/pokemon-stat.ts diff --git a/src/data/pokemon-stat.ts b/src/data/pokemon-stat.ts index 228d25a74ea..b22eaefe876 100644 --- a/src/data/pokemon-stat.ts +++ b/src/data/pokemon-stat.ts @@ -1,3 +1,5 @@ +import i18next from '../plugins/i18n'; + export enum Stat { HP = 0, ATK, @@ -11,22 +13,22 @@ export function getStatName(stat: Stat, shorten: boolean = false) { let ret: string; switch (stat) { case Stat.HP: - ret = !shorten ? 'Max. HP' : 'MaxHP'; + ret = !shorten ? i18next.t('pokemonStat:HP') : i18next.t('pokemonStat:HPshortened'); break; case Stat.ATK: - ret = !shorten ? 'Attack' : 'Atk'; + ret = !shorten ? i18next.t('pokemonStat:ATK') : i18next.t('pokemonStat:ATKshortened'); break; case Stat.DEF: - ret = !shorten ? 'Defense' : 'Def'; + ret = !shorten ? i18next.t('pokemonStat:DEF') : i18next.t('pokemonStat:DEFshortened'); break; case Stat.SPATK: - ret = !shorten ? 'Sp. Atk' : 'SpAtk'; + ret = !shorten ? i18next.t('pokemonStat:SPATK') : i18next.t('pokemonStat:SPATKshortened'); break; case Stat.SPDEF: - ret = !shorten ? 'Sp. Def' : 'SpDef'; + ret = !shorten ? i18next.t('pokemonStat:SPDEF') : i18next.t('pokemonStat:SPDEFshortened'); break; case Stat.SPD: - ret = !shorten ? 'Speed' : 'Spd'; + ret = !shorten ? i18next.t('pokemonStat:SPD') : i18next.t('pokemonStat:SPDshortened'); break; } return ret; diff --git a/src/locales/en/pokemon-stat.ts b/src/locales/en/pokemon-stat.ts new file mode 100644 index 00000000000..7a209461b11 --- /dev/null +++ b/src/locales/en/pokemon-stat.ts @@ -0,0 +1,16 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const pokemonStat: SimpleTranslationEntries = { + "HP": "Max. HP", + "HPshortened": "MaxHP", + "ATK": "Attack", + "ATKshortened": "Atk", + "DEF": "Defense", + "DEFshortened": "Def", + "SPATK": "Sp. Atk", + "SPATKshortened": "SpAtk", + "SPDEF": "Sp. Def", + "SPDEFshortened": "SpDef", + "SPD": "Speed", + "SPDshortened": "Spd" +} as const; \ No newline at end of file diff --git a/src/locales/es/pokemon-stat.ts b/src/locales/es/pokemon-stat.ts new file mode 100644 index 00000000000..7a209461b11 --- /dev/null +++ b/src/locales/es/pokemon-stat.ts @@ -0,0 +1,16 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const pokemonStat: SimpleTranslationEntries = { + "HP": "Max. HP", + "HPshortened": "MaxHP", + "ATK": "Attack", + "ATKshortened": "Atk", + "DEF": "Defense", + "DEFshortened": "Def", + "SPATK": "Sp. Atk", + "SPATKshortened": "SpAtk", + "SPDEF": "Sp. Def", + "SPDEFshortened": "SpDef", + "SPD": "Speed", + "SPDshortened": "Spd" +} as const; \ No newline at end of file diff --git a/src/locales/fr/pokemon-stat.ts b/src/locales/fr/pokemon-stat.ts new file mode 100644 index 00000000000..3ab39f0af23 --- /dev/null +++ b/src/locales/fr/pokemon-stat.ts @@ -0,0 +1,16 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const pokemonStat: SimpleTranslationEntries = { + "HP": "PV", + "HPshortened": "PV", + "ATK": "Attaque", + "ATKshortened": "Atq", + "DEF": "Défense", + "DEFshortened": "Déf", + "SPATK": "Atq. Spé", + "SPATKshortened": "AtqSp", + "SPDEF": "Déf. Spé", + "SPDEFshortened": "DéfSp", + "SPD": "Vitesse", + "SPDshortened": "Vit" +} as const; \ No newline at end of file diff --git a/src/locales/it/pokemon-stat.ts b/src/locales/it/pokemon-stat.ts new file mode 100644 index 00000000000..7a209461b11 --- /dev/null +++ b/src/locales/it/pokemon-stat.ts @@ -0,0 +1,16 @@ +import { SimpleTranslationEntries } from "#app/plugins/i18n"; + +export const pokemonStat: SimpleTranslationEntries = { + "HP": "Max. HP", + "HPshortened": "MaxHP", + "ATK": "Attack", + "ATKshortened": "Atk", + "DEF": "Defense", + "DEFshortened": "Def", + "SPATK": "Sp. Atk", + "SPATKshortened": "SpAtk", + "SPDEF": "Sp. Def", + "SPDEFshortened": "SpDef", + "SPD": "Speed", + "SPDshortened": "Spd" +} as const; \ No newline at end of file diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 23a7a8e1d7d..31ddc2d6c79 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -16,6 +16,11 @@ import { pokemon as enPokemon } from '../locales/en/pokemon'; import { pokemon as esPokemon } from '../locales/es/pokemon'; import { pokemon as frPokemon } from '../locales/fr/pokemon'; +import { pokemonStat as enPokemonStat } from '../locales/en/pokemon-stat'; +import { pokemonStat as esPokemonStat } from '../locales/es/pokemon-stat'; +import { pokemonStat as frPokemonStat } from '../locales/fr/pokemon-stat'; +import { pokemonStat as itPokemonStat } from '../locales/it/pokemon-stat'; + import { commandUiHandler as enCommandUiHandler } from '../locales/en/command-ui-handler'; import { commandUiHandler as esCommandUiHandler } from '../locales/es/command-ui-handler'; import { commandUiHandler as frCommandUiHandler } from '../locales/fr/command-ui-handler'; @@ -71,6 +76,7 @@ export function initI18n(): void { move: enMove, pokeball: enPokeball, pokemon: enPokemon, + pokemonStat: enPokemonStat, commandUiHandler: enCommandUiHandler, }, es: { @@ -78,6 +84,7 @@ export function initI18n(): void { move: esMove, pokeball: esPokeball, pokemon: esPokemon, + pokemonStat: esPokemonStat, commandUiHandler: esCommandUiHandler, }, fr: { @@ -85,10 +92,12 @@ export function initI18n(): void { move: frMove, pokeball: frPokeball, pokemon: frPokemon, + pokemonStat: frPokemonStat, commandUiHandler: frCommandUiHandler, }, it: { menu: itMenu, + pokemonStat: itPokemonStat, }, }, }); @@ -102,6 +111,7 @@ declare module 'i18next' { move: typeof enMove; pokeball: typeof enPokeball; pokemon: typeof enPokemon; + pokemonStat: typeof enPokemonStat; commandUiHandler: typeof enCommandUiHandler; }; }