From 40afdd2c6ada08caee62028e7f78127c19d0a602 Mon Sep 17 00:00:00 2001 From: Juan-Lucas Date: Tue, 23 Apr 2024 18:37:47 +0200 Subject: [PATCH] command-ui: add i18n for command ui handler and add i18n for fr --- src/locales/en/command-ui-handler.ts | 9 +++++++++ src/locales/fr/command-ui-handler.ts | 9 +++++++++ src/plugins/i18n.ts | 7 +++++++ src/ui/command-ui-handler.ts | 10 ++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/locales/en/command-ui-handler.ts create mode 100644 src/locales/fr/command-ui-handler.ts diff --git a/src/locales/en/command-ui-handler.ts b/src/locales/en/command-ui-handler.ts new file mode 100644 index 00000000000..889c1378b08 --- /dev/null +++ b/src/locales/en/command-ui-handler.ts @@ -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; \ No newline at end of file diff --git a/src/locales/fr/command-ui-handler.ts b/src/locales/fr/command-ui-handler.ts new file mode 100644 index 00000000000..3df0ba58587 --- /dev/null +++ b/src/locales/fr/command-ui-handler.ts @@ -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; \ No newline at end of file diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 65565dc8eda..bf7a26c610e 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -15,10 +15,14 @@ import { pokeball as frPokeball } from '../locales/fr/pokeball'; import { pokemon as enPokemon } from '../locales/en/pokemon'; import { pokemon as frPokemon } from '../locales/fr/pokemon'; +import { commandUiHandler as enCommandUiHandler } from '../locales/en/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,6 +69,7 @@ export function initI18n(): void { move: enMove, pokeball: enPokeball, pokemon: enPokemon, + commandUiHandler: enCommandUiHandler, }, es: { menu: esMenu, @@ -79,6 +84,7 @@ export function initI18n(): void { move: frMove, pokeball: frPokeball, pokemon: frPokemon, + commandUiHandler: frCommandUiHandler, } }, }); @@ -92,6 +98,7 @@ declare module 'i18next' { move: typeof enMove; pokeball: typeof enPokeball; pokemon: typeof enPokemon; + commandUiHandler: typeof enCommandUiHandler; }; } } diff --git a/src/ui/command-ui-handler.ts b/src/ui/command-ui-handler.ts index c0fdd43fa84..b8223694b4c 100644 --- a/src/ui/command-ui-handler.ts +++ b/src/ui/command-ui-handler.ts @@ -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;