command-ui: add i18n for command ui handler and add i18n for fr (#258)

* command-ui: add i18n for command ui handler and add i18n for fr

* Add missing Spanish file

* Add additional missing localization references

---------

Co-authored-by: Flashfyre <flashfireex@gmail.com>
This commit is contained in:
Juan-Lucas 2024-04-24 06:36:07 +02:00 committed by GitHub
parent ea40bd18f5
commit 1b1578d266
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1136 additions and 6 deletions

View File

@ -0,0 +1,9 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const commandUiHandler: SimpleTranslationEntries = {
"fight": "Fight",
"ball": "Ball",
"pokemon": "Pokémon",
"run": "Run",
"actionMessage": "What will\n{{pokemonName}} do?",
} as const;

View File

@ -0,0 +1,9 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const commandUiHandler: SimpleTranslationEntries = {
"fight": "Fight",
"ball": "Ball",
"pokemon": "Pokémon",
"run": "Run",
"actionMessage": "What will\n{{pokemonName}} do?",
} as const;

1086
src/locales/es/pokemon.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
import { SimpleTranslationEntries } from "#app/plugins/i18n";
export const commandUiHandler: SimpleTranslationEntries = {
"fight": "Attaque",
"ball": "Ball",
"pokemon": "Pokémon",
"run": "Fuite",
"actionMessage": "Que doit faire\n{{pokemonName}}?",
} as const;

View File

@ -13,12 +13,18 @@ import { pokeball as esPokeball } from '../locales/es/pokeball';
import { pokeball as frPokeball } from '../locales/fr/pokeball';
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 { 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';
export interface SimpleTranslationEntries {
[key: string]: string
}
export interface MoveTranslationEntry {
name: string,
effect: string
@ -65,21 +71,25 @@ export function initI18n(): void {
move: enMove,
pokeball: enPokeball,
pokemon: enPokemon,
commandUiHandler: enCommandUiHandler,
},
es: {
menu: esMenu,
move: esMove,
pokeball: esPokeball,
},
it: {
menu: itMenu,
pokemon: esPokemon,
commandUiHandler: esCommandUiHandler,
},
fr: {
menu: frMenu,
move: frMove,
pokeball: frPokeball,
pokemon: frPokemon,
}
commandUiHandler: frCommandUiHandler,
},
it: {
menu: itMenu,
},
},
});
}
@ -92,6 +102,7 @@ declare module 'i18next' {
move: typeof enMove;
pokeball: typeof enPokeball;
pokemon: typeof enPokemon;
commandUiHandler: typeof enCommandUiHandler;
};
}
}

View File

@ -4,6 +4,7 @@ import { addTextObject, TextStyle } from "./text";
import PartyUiHandler, { PartyUiMode } from "./party-ui-handler";
import { Mode } from "./ui";
import UiHandler from "./ui-handler";
import i18next from '../plugins/i18n';
export enum Command {
FIGHT = 0,
@ -25,7 +26,12 @@ export default class CommandUiHandler extends UiHandler {
setup() {
const ui = this.getUi();
const commands = [ 'Fight', 'Ball', 'Pokémon', 'Run' ];
const commands = [
i18next.t('commandUiHandler:fight'),
i18next.t('commandUiHandler:ball'),
i18next.t('commandUiHandler:pokemon'),
i18next.t('commandUiHandler:run')
];
this.commandsContainer = this.scene.add.container(216, -38.7);
this.commandsContainer.setVisible(false);
@ -55,7 +61,7 @@ export default class CommandUiHandler extends UiHandler {
messageHandler.commandWindow.setVisible(true);
messageHandler.movesWindowContainer.setVisible(false);
messageHandler.message.setWordWrapWidth(1110);
messageHandler.showText(`What will\n${commandPhase.getPokemon().name} do?`, 0);
messageHandler.showText(i18next.t('commandUiHandler:actionMessage', {pokemonName: commandPhase.getPokemon().name}), 0);
this.setCursor(this.getCursor());
return true;