Implement localisation for pokemon stats & add french locale

pull/249/merge
Edralo 2024-04-24 22:10:03 +02:00 committed by Samuel H
parent ad818aa314
commit dc575d44a3
6 changed files with 82 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import i18next from '../plugins/i18n';
export enum Stat { export enum Stat {
HP = 0, HP = 0,
ATK, ATK,
@ -11,22 +13,22 @@ export function getStatName(stat: Stat, shorten: boolean = false) {
let ret: string; let ret: string;
switch (stat) { switch (stat) {
case Stat.HP: case Stat.HP:
ret = !shorten ? 'Max. HP' : 'MaxHP'; ret = !shorten ? i18next.t('pokemonStat:HP') : i18next.t('pokemonStat:HPshortened');
break; break;
case Stat.ATK: case Stat.ATK:
ret = !shorten ? 'Attack' : 'Atk'; ret = !shorten ? i18next.t('pokemonStat:ATK') : i18next.t('pokemonStat:ATKshortened');
break; break;
case Stat.DEF: case Stat.DEF:
ret = !shorten ? 'Defense' : 'Def'; ret = !shorten ? i18next.t('pokemonStat:DEF') : i18next.t('pokemonStat:DEFshortened');
break; break;
case Stat.SPATK: case Stat.SPATK:
ret = !shorten ? 'Sp. Atk' : 'SpAtk'; ret = !shorten ? i18next.t('pokemonStat:SPATK') : i18next.t('pokemonStat:SPATKshortened');
break; break;
case Stat.SPDEF: case Stat.SPDEF:
ret = !shorten ? 'Sp. Def' : 'SpDef'; ret = !shorten ? i18next.t('pokemonStat:SPDEF') : i18next.t('pokemonStat:SPDEFshortened');
break; break;
case Stat.SPD: case Stat.SPD:
ret = !shorten ? 'Speed' : 'Spd'; ret = !shorten ? i18next.t('pokemonStat:SPD') : i18next.t('pokemonStat:SPDshortened');
break; break;
} }
return ret; return ret;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -16,6 +16,11 @@ import { pokemon as enPokemon } from '../locales/en/pokemon';
import { pokemon as esPokemon } from '../locales/es/pokemon'; import { pokemon as esPokemon } from '../locales/es/pokemon';
import { pokemon as frPokemon } from '../locales/fr/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 enCommandUiHandler } from '../locales/en/command-ui-handler';
import { commandUiHandler as esCommandUiHandler } from '../locales/es/command-ui-handler'; import { commandUiHandler as esCommandUiHandler } from '../locales/es/command-ui-handler';
import { commandUiHandler as frCommandUiHandler } from '../locales/fr/command-ui-handler'; import { commandUiHandler as frCommandUiHandler } from '../locales/fr/command-ui-handler';
@ -71,6 +76,7 @@ export function initI18n(): void {
move: enMove, move: enMove,
pokeball: enPokeball, pokeball: enPokeball,
pokemon: enPokemon, pokemon: enPokemon,
pokemonStat: enPokemonStat,
commandUiHandler: enCommandUiHandler, commandUiHandler: enCommandUiHandler,
}, },
es: { es: {
@ -78,6 +84,7 @@ export function initI18n(): void {
move: esMove, move: esMove,
pokeball: esPokeball, pokeball: esPokeball,
pokemon: esPokemon, pokemon: esPokemon,
pokemonStat: esPokemonStat,
commandUiHandler: esCommandUiHandler, commandUiHandler: esCommandUiHandler,
}, },
fr: { fr: {
@ -85,10 +92,12 @@ export function initI18n(): void {
move: frMove, move: frMove,
pokeball: frPokeball, pokeball: frPokeball,
pokemon: frPokemon, pokemon: frPokemon,
pokemonStat: frPokemonStat,
commandUiHandler: frCommandUiHandler, commandUiHandler: frCommandUiHandler,
}, },
it: { it: {
menu: itMenu, menu: itMenu,
pokemonStat: itPokemonStat,
}, },
}, },
}); });
@ -102,6 +111,7 @@ declare module 'i18next' {
move: typeof enMove; move: typeof enMove;
pokeball: typeof enPokeball; pokeball: typeof enPokeball;
pokemon: typeof enPokemon; pokemon: typeof enPokemon;
pokemonStat: typeof enPokemonStat;
commandUiHandler: typeof enCommandUiHandler; commandUiHandler: typeof enCommandUiHandler;
}; };
} }