From e34b20466426a9944a71306b993c6d149eeabd20 Mon Sep 17 00:00:00 2001 From: TeKrop Date: Wed, 1 May 2024 22:48:58 +0200 Subject: [PATCH] feat: added support for localisation on battle scene sentences --- src/field/pokemon.ts | 13 +++++++------ src/locales/de/menu.ts | 7 ++++++- src/locales/en/menu.ts | 7 ++++++- src/locales/es/menu.ts | 7 ++++++- src/locales/fr/menu.ts | 7 ++++++- src/locales/it/menu.ts | 7 ++++++- 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index ce2d8dfff..8c9224f5e 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -45,6 +45,7 @@ import { TerrainType } from '../data/terrain'; import { TrainerSlot } from '../data/trainer-config'; import { BerryType } from '../data/berry'; import { ABILITY_OVERRIDE, MOVE_OVERRIDE, OPP_ABILITY_OVERRIDE, OPP_MOVE_OVERRIDE, OPP_SHINY_OVERRIDE, OPP_VARIANT_OVERRIDE } from '../overrides'; +import i18next from '../plugins/i18n'; export enum FieldPosition { CENTER, @@ -1417,7 +1418,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { damage.value = this.damageAndUpdate(damage.value, result as DamageResult, isCritical, oneHitKo, oneHitKo); this.turnData.damageTaken += damage.value; if (isCritical) - this.scene.queueMessage('A critical hit!'); + this.scene.queueMessage(i18next.t('menu:hitResultCriticalHit')); this.scene.setPhaseQueueSplice(); if (source.isPlayer()) { this.scene.validateAchvs(DamageAchv, damage); @@ -1435,16 +1436,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (source.turnData.hitsLeft === 1) { switch (result) { case HitResult.SUPER_EFFECTIVE: - this.scene.queueMessage('It\'s super effective!'); + this.scene.queueMessage(i18next.t('menu:hitResultSuperEffective')); break; case HitResult.NOT_VERY_EFFECTIVE: - this.scene.queueMessage('It\'s not very effective…'); + this.scene.queueMessage(i18next.t('menu:hitResultNotVeryEffective')); break; case HitResult.NO_EFFECT: - this.scene.queueMessage(`It doesn\'t affect ${this.name}!`); + this.scene.queueMessage(i18next.t('menu:hitResultNoEffect', { pokemonName: this.name })); break; case HitResult.ONE_HIT_KO: - this.scene.queueMessage('It\'s a one-hit KO!'); + this.scene.queueMessage(i18next.t('menu:hitResultOneHitKO')); break; } } @@ -1461,7 +1462,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { defendingSidePlayField.forEach((p) => applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, battlerMove, cancelled, typeMultiplier)); } if (!typeMultiplier.value) - this.scene.queueMessage(`It doesn\'t affect ${this.name}!`); + this.scene.queueMessage(i18next.t('menu:hitResultNoEffect', { pokemonName: this.name })); result = cancelled.value || !typeMultiplier.value ? HitResult.NO_EFFECT : HitResult.STATUS; break; } diff --git a/src/locales/de/menu.ts b/src/locales/de/menu.ts index 442cfae21..a8e0a901f 100644 --- a/src/locales/de/menu.ts +++ b/src/locales/de/menu.ts @@ -63,5 +63,10 @@ export const menu: SimpleTranslationEntries = { "weeklyRankings": "Weekly Rankings", "noRankings": "No Rankings", "loading": "Loading…", - "playersOnline": "Players Online" + "playersOnline": "Players Online", + "hitResultCriticalHit": "A critical hit!", + "hitResultSuperEffective": "It's super effective!", + "hitResultNotVeryEffective": "It's not very effective…", + "hitResultNoEffect": "It doesn't affect {{pokemonName}}!", + "hitResultOneHitKO": "It's a one-hit KO!" } as const; \ No newline at end of file diff --git a/src/locales/en/menu.ts b/src/locales/en/menu.ts index 82a09e49d..21620e9b3 100644 --- a/src/locales/en/menu.ts +++ b/src/locales/en/menu.ts @@ -82,5 +82,10 @@ export const menu: SimpleTranslationEntries = { "weeklyRankings": "Weekly Rankings", "noRankings": "No Rankings", "loading": "Loading…", - "playersOnline": "Players Online" + "playersOnline": "Players Online", + "hitResultCriticalHit": "A critical hit!", + "hitResultSuperEffective": "It's super effective!", + "hitResultNotVeryEffective": "It's not very effective…", + "hitResultNoEffect": "It doesn't affect {{pokemonName}}!", + "hitResultOneHitKO": "It's a one-hit KO!" } as const; \ No newline at end of file diff --git a/src/locales/es/menu.ts b/src/locales/es/menu.ts index 5dccc2e4e..0a43f19b7 100644 --- a/src/locales/es/menu.ts +++ b/src/locales/es/menu.ts @@ -66,5 +66,10 @@ export const menu: SimpleTranslationEntries = { "weeklyRankings": "Weekly Rankings", "noRankings": "No Rankings", "loading": "Loading…", - "playersOnline": "Players Online" + "playersOnline": "Players Online", + "hitResultCriticalHit": "A critical hit!", + "hitResultSuperEffective": "It's super effective!", + "hitResultNotVeryEffective": "It's not very effective…", + "hitResultNoEffect": "It doesn't affect {{pokemonName}}!", + "hitResultOneHitKO": "It's a one-hit KO!" } as const; \ No newline at end of file diff --git a/src/locales/fr/menu.ts b/src/locales/fr/menu.ts index d5478c67a..c485412bf 100644 --- a/src/locales/fr/menu.ts +++ b/src/locales/fr/menu.ts @@ -77,5 +77,10 @@ export const menu: SimpleTranslationEntries = { "weeklyRankings": "Classement de la Semaine", "noRankings": "Pas de Classement", "loading": "Chargement…", - "playersOnline": "Joueurs Connectés" + "playersOnline": "Joueurs Connectés", + "hitResultCriticalHit": "Coup critique!", + "hitResultSuperEffective": "C'est super efficace!", + "hitResultNotVeryEffective": "Ce n'est pas très efficace…", + "hitResultNoEffect": "Ça n'affecte pas {{pokemonName}}…", + "hitResultOneHitKO": "K.O. en un coup!" } as const; diff --git a/src/locales/it/menu.ts b/src/locales/it/menu.ts index c37a37b51..118c1dccb 100644 --- a/src/locales/it/menu.ts +++ b/src/locales/it/menu.ts @@ -11,5 +11,10 @@ export const menu: SimpleTranslationEntries = { "weeklyRankings": "Weekly Rankings", "noRankings": "No Rankings", "loading": "Loading…", - "playersOnline": "Players Online" + "playersOnline": "Players Online", + "hitResultCriticalHit": "A critical hit!", + "hitResultSuperEffective": "It's super effective!", + "hitResultNotVeryEffective": "It's not very effective…", + "hitResultNoEffect": "It doesn't affect {{pokemonName}}!", + "hitResultOneHitKO": "It's a one-hit KO!" } as const; \ No newline at end of file