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

This commit is contained in:
Juan-Lucas 2024-04-23 18:37:47 +02:00
parent 049fa306b9
commit 40afdd2c6a
4 changed files with 33 additions and 2 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": "Attaque",
"ball": "Ball",
"pokemon": "Pokémon",
"run": "Fuite",
"actionMessage": "Que doit faire\n{{pokemonName}}?",
} as const;

View File

@ -15,10 +15,14 @@ import { pokeball as frPokeball } from '../locales/fr/pokeball';
import { pokemon as enPokemon } from '../locales/en/pokemon'; import { pokemon as enPokemon } from '../locales/en/pokemon';
import { pokemon as frPokemon } from '../locales/fr/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 { export interface SimpleTranslationEntries {
[key: string]: string [key: string]: string
} }
export interface MoveTranslationEntry { export interface MoveTranslationEntry {
name: string, name: string,
effect: string effect: string
@ -65,6 +69,7 @@ export function initI18n(): void {
move: enMove, move: enMove,
pokeball: enPokeball, pokeball: enPokeball,
pokemon: enPokemon, pokemon: enPokemon,
commandUiHandler: enCommandUiHandler,
}, },
es: { es: {
menu: esMenu, menu: esMenu,
@ -79,6 +84,7 @@ export function initI18n(): void {
move: frMove, move: frMove,
pokeball: frPokeball, pokeball: frPokeball,
pokemon: frPokemon, pokemon: frPokemon,
commandUiHandler: frCommandUiHandler,
} }
}, },
}); });
@ -92,6 +98,7 @@ declare module 'i18next' {
move: typeof enMove; move: typeof enMove;
pokeball: typeof enPokeball; pokeball: typeof enPokeball;
pokemon: typeof enPokemon; 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 PartyUiHandler, { PartyUiMode } from "./party-ui-handler";
import { Mode } from "./ui"; import { Mode } from "./ui";
import UiHandler from "./ui-handler"; import UiHandler from "./ui-handler";
import i18next from '../plugins/i18n';
export enum Command { export enum Command {
FIGHT = 0, FIGHT = 0,
@ -25,7 +26,12 @@ export default class CommandUiHandler extends UiHandler {
setup() { setup() {
const ui = this.getUi(); 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 = this.scene.add.container(216, -38.7);
this.commandsContainer.setVisible(false); this.commandsContainer.setVisible(false);
@ -55,7 +61,7 @@ export default class CommandUiHandler extends UiHandler {
messageHandler.commandWindow.setVisible(true); messageHandler.commandWindow.setVisible(true);
messageHandler.movesWindowContainer.setVisible(false); messageHandler.movesWindowContainer.setVisible(false);
messageHandler.message.setWordWrapWidth(1110); 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()); this.setCursor(this.getCursor());
return true; return true;