From f53dce432be4c16d9b89356ef16d859a0e94b44f Mon Sep 17 00:00:00 2001 From: Laeticia PIERRE Date: Thu, 6 Jun 2024 15:36:12 +0200 Subject: [PATCH] useMove + pokemon affix localization (#1276) * useMove + pokemonPrefix localization * Rename prefix to affix + line break fr * getPokemonAffix to getPokemonNameWithAffix + remove space + replace * Better getPokemonNameWithAffix switch * Ko locale + fix es locale * Doc getPokemonNameWithAffix + getPokemonMessage + fix * Ko translate / missing weather changes * Fix conflicts getPokemonPrefix --------- Co-authored-by: Benjamin Odom --- src/data/ability.ts | 8 ++++---- src/data/battler-tags.ts | 6 +++--- src/data/weather.ts | 6 +++--- src/locales/de/battle.ts | 3 +++ src/locales/de/weather.ts | 4 ++-- src/locales/en/battle.ts | 3 +++ src/locales/en/weather.ts | 4 ++-- src/locales/es/battle.ts | 3 +++ src/locales/es/weather.ts | 4 ++-- src/locales/fr/battle.ts | 3 +++ src/locales/fr/weather.ts | 4 ++-- src/locales/it/battle.ts | 3 +++ src/locales/it/weather.ts | 4 ++-- src/locales/ko/battle.ts | 5 ++++- src/locales/ko/weather.ts | 4 ++-- src/locales/pt_BR/battle.ts | 3 +++ src/locales/pt_BR/weather.ts | 4 ++-- src/locales/zh_CN/battle.ts | 3 +++ src/locales/zh_CN/weather.ts | 4 ++-- src/locales/zh_TW/battle.ts | 3 +++ src/locales/zh_TW/weather.ts | 4 ++-- src/messages.ts | 37 ++++++++++++++++++++++++++++-------- src/phases.ts | 14 ++++++++++---- 23 files changed, 95 insertions(+), 41 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 0a7b86e3e2b..4bb4f36350e 100755 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3,7 +3,7 @@ import { Type } from "./type"; import * as Utils from "../utils"; import { BattleStat, getBattleStatName } from "./battle-stat"; import { MovePhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases"; -import { getPokemonMessage, getPokemonPrefix } from "../messages"; +import { getPokemonMessage, getPokemonNameWithAffix } from "../messages"; import { Weather, WeatherType } from "./weather"; import { BattlerTag } from "./battler-tags"; import { BattlerTagType } from "./enums/battler-tag-type"; @@ -156,7 +156,7 @@ export class BlockRecoilDamageAttr extends AbAttr { } getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]) { - return i18next.t("abilityTriggers:blockRecoilDamage", {pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, abilityName: abilityName}); + return i18next.t("abilityTriggers:blockRecoilDamage", {pokemonName: getPokemonNameWithAffix(pokemon), abilityName: abilityName}); } } @@ -878,7 +878,7 @@ export class PostDefendPerishSongAbAttr extends PostDefendAbAttr { } getTriggerMessage(pokemon: Pokemon, abilityName: string, ...args: any[]): string { - return i18next.t("abilityTriggers:perishBody", {pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, abilityName: abilityName}); + return i18next.t("abilityTriggers:perishBody", {pokemonName: getPokemonNameWithAffix(pokemon), abilityName: abilityName}); } } @@ -2666,7 +2666,7 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr { for (const opp of pokemon.getOpponents()) { if (opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(Abilities.COMATOSE)) { opp.damageAndUpdate(Math.floor(Math.max(1, opp.getMaxHp() / 8)), HitResult.OTHER); - pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: `${getPokemonPrefix(opp)}${opp.name}`})); + pokemon.scene.queueMessage(i18next.t("abilityTriggers:badDreams", {pokemonName: getPokemonNameWithAffix(opp)})); hadEffect = true; } diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 48083cba00d..50d4b62decb 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -1,6 +1,6 @@ import { CommonAnim, CommonBattleAnim } from "./battle-anims"; import { CommonAnimPhase, MoveEffectPhase, MovePhase, PokemonHealPhase, ShowAbilityPhase, StatChangePhase } from "../phases"; -import { getPokemonMessage, getPokemonPrefix } from "../messages"; +import { getPokemonMessage, getPokemonNameWithAffix } from "../messages"; import Pokemon, { MoveResult, HitResult } from "../field/pokemon"; import { Stat, getStatName } from "./pokemon-stat"; import { StatusEffect } from "./status-effect"; @@ -803,7 +803,7 @@ export class ThunderCageTag extends DamagingTrapTag { } getTrapMessage(pokemon: Pokemon): string { - return getPokemonMessage(pokemon.scene.getPokemonById(this.sourceId), ` trapped\n${getPokemonPrefix(pokemon).toLowerCase()}${pokemon.name}!`); + return getPokemonMessage(pokemon.scene.getPokemonById(this.sourceId), ` trapped\n${getPokemonNameWithAffix(pokemon)}!`); } } @@ -813,7 +813,7 @@ export class InfestationTag extends DamagingTrapTag { } getTrapMessage(pokemon: Pokemon): string { - return getPokemonMessage(pokemon, ` has been afflicted \nwith an infestation by ${getPokemonPrefix(pokemon.scene.getPokemonById(this.sourceId))}${pokemon.scene.getPokemonById(this.sourceId).name}!`); + return getPokemonMessage(pokemon, ` has been afflicted \nwith an infestation by ${getPokemonNameWithAffix(pokemon.scene.getPokemonById(this.sourceId))}!`); } } diff --git a/src/data/weather.ts b/src/data/weather.ts index f2b4136f51c..1df94b02da1 100644 --- a/src/data/weather.ts +++ b/src/data/weather.ts @@ -1,5 +1,5 @@ import { Biome } from "./enums/biome"; -import { getPokemonMessage, getPokemonPrefix } from "../messages"; +import { getPokemonMessage, getPokemonNameWithAffix } from "../messages"; import Pokemon from "../field/pokemon"; import { Type } from "./type"; import Move, { AttackMove } from "./move"; @@ -180,9 +180,9 @@ export function getWeatherLapseMessage(weatherType: WeatherType): string { export function getWeatherDamageMessage(weatherType: WeatherType, pokemon: Pokemon): string { switch (weatherType) { case WeatherType.SANDSTORM: - return i18next.t("weather:sandstormDamageMessage", {pokemonPrefix: getPokemonPrefix(pokemon), pokemonName: pokemon.name}); + return i18next.t("weather:sandstormDamageMessage", {pokemonNameWithAffix: getPokemonNameWithAffix(pokemon)}); case WeatherType.HAIL: - return i18next.t("weather:hailDamageMessage", {pokemonPrefix: getPokemonPrefix(pokemon), pokemonName: pokemon.name}); + return i18next.t("weather:hailDamageMessage", {pokemonNameWithAffix: getPokemonNameWithAffix(pokemon)}); } return null; diff --git a/src/locales/de/battle.ts b/src/locales/de/battle.ts index 8c153aa77eb..d588fb327c6 100644 --- a/src/locales/de/battle.ts +++ b/src/locales/de/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "notDisabled": "{{pokemonName}}'s {{moveName}} ist\nnicht mehr deaktiviert!", "eggHatching": "Oh?", "ivScannerUseQuestion": "IV-Scanner auf {{pokemonName}} benutzen?", + "wildPokemonWithAffix": "{{pokemonName}} (wild)", + "foePokemonWithAffix": "{{pokemonName}} (Gegner)", + "useMove": "{{pokemonNameWithAffix}} setzt {{moveName}} ein!", "drainMessage": "{{pokemonName}} wurde Energie abgesaugt", "regainHealth": "KP von {{pokemonName}} wurden wieder aufgefrischt!" } as const; diff --git a/src/locales/de/weather.ts b/src/locales/de/weather.ts index f6a6864bec7..ab1dde97639 100644 --- a/src/locales/de/weather.ts +++ b/src/locales/de/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "Ein Sandsturm kommt auf!", "sandstormLapseMessage": "Der Sandsturm tobt.", "sandstormClearMessage": "Der Sandsturm legt sich.", - "sandstormDamageMessage": " Der Sandsturm fügt {{pokemonPrefix}}{{pokemonName}} Schaden zu!", + "sandstormDamageMessage": " Der Sandsturm fügt {{pokemonNameWithAffix}} Schaden zu!", "hailStartMessage": "Es fängt an zu hageln!", "hailLapseMessage": "Der Hagelsturm tobt.", "hailClearMessage": "Der Hagelsturm legt sich.", - "hailDamageMessage": "{{pokemonPrefix}}{{pokemonName}} wird von Hagelkörnern getroffen!", + "hailDamageMessage": "{{pokemonNameWithAffix}} wird von Hagelkörnern getroffen!", "snowStartMessage": "Es fängt an zu schneien!", "snowLapseMessage": "Der Schneesturm tobt.", diff --git a/src/locales/en/battle.ts b/src/locales/en/battle.ts index a3fa41d9b76..083de089961 100644 --- a/src/locales/en/battle.ts +++ b/src/locales/en/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "Are you sure you want to skip taking an item?", "eggHatching": "Oh?", "ivScannerUseQuestion": "Use IV Scanner on {{pokemonName}}?", + "wildPokemonWithAffix": "Wild {{pokemonName}}", + "foePokemonWithAffix": "Foe {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}} used {{moveName}}!", "drainMessage": "{{pokemonName}} had its\nenergy drained!", "regainHealth": "{{pokemonName}} regained\nhealth!" } as const; diff --git a/src/locales/en/weather.ts b/src/locales/en/weather.ts index 1e4602f362c..513c2181b00 100644 --- a/src/locales/en/weather.ts +++ b/src/locales/en/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "A sandstorm brewed!", "sandstormLapseMessage": "The sandstorm rages.", "sandstormClearMessage": "The sandstorm subsided.", - "sandstormDamageMessage": "{{pokemonPrefix}}{{pokemonName}} is buffeted\nby the sandstorm!", + "sandstormDamageMessage": "{{pokemonNameWithAffix}} is buffeted\nby the sandstorm!", "hailStartMessage": "It started to hail!", "hailLapseMessage": "Hail continues to fall.", "hailClearMessage": "The hail stopped.", - "hailDamageMessage": "{{pokemonPrefix}}{{pokemonName}} is pelted\nby the hail!", + "hailDamageMessage": "{{pokemonNameWithAffix}} is pelted\nby the hail!", "snowStartMessage": "It started to snow!", "snowLapseMessage": "The snow is falling down.", diff --git a/src/locales/es/battle.ts b/src/locales/es/battle.ts index af090153a04..c4d79cfdb93 100644 --- a/src/locales/es/battle.ts +++ b/src/locales/es/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "¿Estás seguro de que no quieres coger un objeto?", "eggHatching": "¿Y esto?", "ivScannerUseQuestion": "¿Quieres usar el Escáner de IVs en {{pokemonName}}?", + "wildPokemonWithAffix": "Wild {{pokemonName}}", + "foePokemonWithAffix": "Foe {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}} used {{moveName}}!", "drainMessage": "{{pokemonName}} had its\nenergy drained!", "regainHealth": "{{pokemonName}} regained\nhealth!" } as const; diff --git a/src/locales/es/weather.ts b/src/locales/es/weather.ts index a5ba94d1e7d..1e40544accd 100644 --- a/src/locales/es/weather.ts +++ b/src/locales/es/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "¡Se ha desatado una tormenta de arena!", "sandstormLapseMessage": "La tormenta de arena arrecia...", "sandstormClearMessage": "La tormenta de arena termino.", - "sandstormDamageMessage": "¡La tormenta de arena zarandea al\n{{pokemonName}} {{pokemonPrefix}}!", + "sandstormDamageMessage": "¡La tormenta de arena zarandea al\n{{pokemonNameWithAffix}}!", "hailStartMessage": "¡Ha empezado a granizar!", "hailLapseMessage": "Sigue granizando...", "hailClearMessage": "Had dejado de granizar.", - "hailDamageMessage": "El granizo golpea al\n{{pokemonName}} {{pokemonPrefix}}!", + "hailDamageMessage": "El granizo golpea al\n{{pokemonNameWithAffix}}!", "snowStartMessage": "¡Ha empezado a nevar!", "snowLapseMessage": "Sigue nevando...", diff --git a/src/locales/fr/battle.ts b/src/locales/fr/battle.ts index 535ed4b6ade..181b85f7cc8 100644 --- a/src/locales/fr/battle.ts +++ b/src/locales/fr/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "Êtes-vous sûr·e de ne pas vouloir prendre d’objet ?", "eggHatching": "Oh ?", "ivScannerUseQuestion": "Utiliser le Scanner d’IV sur {{pokemonName}} ?", + "wildPokemonWithAffix": "{{pokemonName}} sauvage", + "foePokemonWithAffix": "{{pokemonName}} ennemi", + "useMove": "{{pokemonNameWithAffix}} utilise\n{{moveName}} !", "drainMessage": "{{pokemonName}} had its\nenergy drained!", "regainHealth": "{{pokemonName}} regained\nhealth!" } as const; diff --git a/src/locales/fr/weather.ts b/src/locales/fr/weather.ts index 76d56887578..5c483d71b44 100644 --- a/src/locales/fr/weather.ts +++ b/src/locales/fr/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "Une tempête de sable se prépare !", "sandstormLapseMessage": "La tempête de sable fait rage !", "sandstormClearMessage": "La tempête de sable se calme !", - "sandstormDamageMessage": "La tempête de sable inflige des dégâts\nà {{pokemonPrefix}}{{pokemonName}} !", + "sandstormDamageMessage": "La tempête de sable inflige des dégâts\nà {{pokemonNameWithAffix}} !", "hailStartMessage": "Il commence à grêler !", "hailLapseMessage": "La grêle continue de tomber !", "hailClearMessage": "La grêle s’est arrêtée !", - "hailDamageMessage": "La grêle inflige des dégâts\nà {{pokemonPrefix}}{{pokemonName}} !", + "hailDamageMessage": "La grêle inflige des dégâts\nà {{pokemonNameWithAffix}} !", "snowStartMessage": "Il commence à neiger !", "snowLapseMessage": "Il y a une tempête de neige !", diff --git a/src/locales/it/battle.ts b/src/locales/it/battle.ts index 5b8089e6677..3ea527339f0 100644 --- a/src/locales/it/battle.ts +++ b/src/locales/it/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "Sei sicuro di non voler prendere nessun oggetto?", "eggHatching": "Oh!", "ivScannerUseQuestion": "Vuoi usare lo scanner di IV su {{pokemonName}}?", + "wildPokemonWithAffix": "Wild {{pokemonName}}", + "foePokemonWithAffix": "Foe {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}} used {{moveName}}!", "drainMessage": "{{pokemonName}} had its\nenergy drained!", "regainHealth": "{{pokemonName}} regained\nhealth!" } as const; diff --git a/src/locales/it/weather.ts b/src/locales/it/weather.ts index 3895fcebc46..ed5d41a80af 100644 --- a/src/locales/it/weather.ts +++ b/src/locales/it/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "Si è scatenata una tempesta di sabbia!", "sandstormLapseMessage": "La tempesta di sabbia infuria.", "sandstormClearMessage": "La tempesta di sabbia si è placata.", - "sandstormDamageMessage": "{{pokemonPrefix}}{{pokemonName}} è stato colpito\ndalla tempesta di sabbia!", + "sandstormDamageMessage": "{{pokemonNameWithAffix}} è stato colpito\ndalla tempesta di sabbia!", "hailStartMessage": "Ha iniziato a grandinare!", "hailLapseMessage": "La grandine continua a cadere.", "hailClearMessage": "Ha smesso di grandinare.", - "hailDamageMessage": "{{pokemonPrefix}}{{pokemonName}} è stato colpito\ndalla grandine!", + "hailDamageMessage": "{{pokemonNameWithAffix}} è stato colpito\ndalla grandine!", "snowStartMessage": "Ha iniziato a nevicare!", "snowLapseMessage": "La neve sta continuando a cadere.", diff --git a/src/locales/ko/battle.ts b/src/locales/ko/battle.ts index c6288d3d9f2..cc91141718c 100644 --- a/src/locales/ko/battle.ts +++ b/src/locales/ko/battle.ts @@ -55,5 +55,8 @@ export const battle: SimpleTranslationEntries = { "notDisabled": "{{pokemonName}}의\n{{moveName}} 사슬묶기가 풀렸다!", "skipItemQuestion": "아이템을 받지 않고 넘어가시겠습니까?", "eggHatching": "어라…?", - "ivScannerUseQuestion": "{{pokemonName}}에게 개체값탐지기를 사용하시겠습니까?" + "ivScannerUseQuestion": "{{pokemonName}}에게 개체값탐지기를 사용하시겠습니까?", + "wildPokemonWithAffix": "야생 {{pokemonName}}", + "foePokemonWithAffix": "상대 {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}}의 {{moveName}}!" } as const; diff --git a/src/locales/ko/weather.ts b/src/locales/ko/weather.ts index 70654d247b6..81340d9567a 100644 --- a/src/locales/ko/weather.ts +++ b/src/locales/ko/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "모래바람이 불기 시작했다!", "sandstormLapseMessage": "모래바람이 세차게 분다", "sandstormClearMessage": "모래바람이 가라앉았다!", - "sandstormDamageMessage": "모래바람이\n{{pokemonPrefix}}{{pokemonName}}[[를]] 덮쳤다!", + "sandstormDamageMessage": "모래바람이\n{{pokemonNameWithAffix}}[[를]] 덮쳤다!", "hailStartMessage": "싸라기눈이 내리기 시작했다!", "hailLapseMessage": "싸라기눈이 계속 내리고 있다", "hailClearMessage": "싸라기눈이 그쳤다!", - "hailDamageMessage": "싸라기눈이\n{{pokemonPrefix}}{{pokemonName}}[[를]] 덮쳤다!", + "hailDamageMessage": "싸라기눈이\n{{pokemonNameWithAffix}}[[를]] 덮쳤다!", "snowStartMessage": "눈이 내리기 시작했다!", "snowLapseMessage": "눈이 계속 내리고 있다", diff --git a/src/locales/pt_BR/battle.ts b/src/locales/pt_BR/battle.ts index f6f471e838a..810aca36b6c 100644 --- a/src/locales/pt_BR/battle.ts +++ b/src/locales/pt_BR/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "Tem certeza de que não quer escolher um item?", "eggHatching": "Opa?", "ivScannerUseQuestion": "Quer usar o Scanner de IVs em {{pokemonName}}?", + "wildPokemonWithAffix": "Wild {{pokemonName}}", + "foePokemonWithAffix": "Foe {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}} used {{moveName}}!", "drainMessage": "{{pokemonName}} teve sua\nenergia drenada!", "regainHealth": "{{pokemonName}} recuperou\npontos de saúde!" } as const; diff --git a/src/locales/pt_BR/weather.ts b/src/locales/pt_BR/weather.ts index 269ba0e3726..07854512fdc 100644 --- a/src/locales/pt_BR/weather.ts +++ b/src/locales/pt_BR/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "Uma tempestade de areia se formou!", "sandstormLapseMessage": "A tempestade de areia é violenta.", "sandstormClearMessage": "A tempestade de areia diminuiu.", - "sandstormDamageMessage": "{{pokemonPrefix}}{{pokemonName}} é atingido\npela tempestade de areia!", + "sandstormDamageMessage": "{{pokemonNameWithAffix}} é atingido\npela tempestade de areia!", "hailStartMessage": "Começou a chover granizo!", "hailLapseMessage": "Granizo cai do céu.", "hailClearMessage": "O granizo parou.", - "hailDamageMessage": "{{pokemonPrefix}}{{pokemonName}} é atingido\npelo granizo!", + "hailDamageMessage": "{{pokemonNameWithAffix}} é atingido\npelo granizo!", "snowStartMessage": "Começou a nevar!", "snowLapseMessage": "A neve continua caindo.", diff --git a/src/locales/zh_CN/battle.ts b/src/locales/zh_CN/battle.ts index cd6357608ac..0fdb962c679 100644 --- a/src/locales/zh_CN/battle.ts +++ b/src/locales/zh_CN/battle.ts @@ -56,6 +56,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "你确定要跳过拾取道具吗?", "eggHatching": "咦?", "ivScannerUseQuestion": "对 {{pokemonName}} 使用个体值扫描仪?", + "wildPokemonWithAffix": "Wild {{pokemonName}}", + "foePokemonWithAffix": "Foe {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}} used {{moveName}}!", "drainMessage": "{{pokemonName}} had its\nenergy drained!", "regainHealth": "{{pokemonName}} regained\nhealth!" } as const; diff --git a/src/locales/zh_CN/weather.ts b/src/locales/zh_CN/weather.ts index 2049b8a429c..874b17f8fe8 100644 --- a/src/locales/zh_CN/weather.ts +++ b/src/locales/zh_CN/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "开始刮沙暴了!", "sandstormLapseMessage": "沙暴肆虐。", "sandstormClearMessage": "沙暴停止了!", - "sandstormDamageMessage": "沙暴袭击了{{pokemonPrefix}}{{pokemonName}}!", + "sandstormDamageMessage": "沙暴袭击了{{pokemonNameWithAffix}}!", "hailStartMessage": "开始下冰雹了!", "hailLapseMessage": "冰雹继续肆虐。", "hailClearMessage": "冰雹不再下了。", - "hailDamageMessage": "冰雹袭击了{{pokemonPrefix}}{{pokemonName}}!", + "hailDamageMessage": "冰雹袭击了{{pokemonNameWithAffix}}!", "snowStartMessage": "开始下雪了!", "snowLapseMessage": "雪继续下。", diff --git a/src/locales/zh_TW/battle.ts b/src/locales/zh_TW/battle.ts index c0846e1cb18..4255aeaef99 100644 --- a/src/locales/zh_TW/battle.ts +++ b/src/locales/zh_TW/battle.ts @@ -53,6 +53,9 @@ export const battle: SimpleTranslationEntries = { "skipItemQuestion": "你要跳過拾取道具嗎?", "eggHatching": "咦?", "ivScannerUseQuestion": "對 {{pokemonName}} 使用個體值掃描?", + "wildPokemonWithAffix": "Wild {{pokemonName}}", + "foePokemonWithAffix": "Foe {{pokemonName}}", + "useMove": "{{pokemonNameWithAffix}} used {{moveName}}!", "drainMessage": "{{pokemonName}} had its\nenergy drained!", "regainHealth": "{{pokemonName}} regained\nhealth!" } as const; diff --git a/src/locales/zh_TW/weather.ts b/src/locales/zh_TW/weather.ts index 0a235b3b10c..03f3425aa43 100644 --- a/src/locales/zh_TW/weather.ts +++ b/src/locales/zh_TW/weather.ts @@ -15,12 +15,12 @@ export const weather: SimpleTranslationEntries = { "sandstormStartMessage": "開始刮沙暴了!", "sandstormLapseMessage": "沙暴肆虐。", "sandstormClearMessage": "沙暴停止了。", - "sandstormDamageMessage": "沙暴襲擊了{{pokemonPrefix}}{{pokemonName}}!", + "sandstormDamageMessage": "沙暴襲擊了{{pokemonNameWithAffix}}!", "hailStartMessage": "開始下冰雹了!", "hailLapseMessage": "冰雹繼續肆虐。", "hailClearMessage": "冰雹不再下了。", - "hailDamageMessage": "冰雹襲擊了{{pokemonPrefix}}{{pokemonName}}!", + "hailDamageMessage": "冰雹襲擊了{{pokemonNameWithAffix}}!", "snowStartMessage": "開始下雪了!", "snowLapseMessage": "雪繼續下。", diff --git a/src/messages.ts b/src/messages.ts index a8549c7356b..e2387094502 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -1,19 +1,40 @@ import { BattleSpec } from "./enums/battle-spec"; import Pokemon from "./field/pokemon"; +import i18next from "./plugins/i18n"; +/** + * Builds a message by concatenating the Pokemon name with its potential affix and the given text + * @param pokemon {@linkcode Pokemon} name and battle context will be retrieved from this instance for {@linkcode getPokemonNameWithAffix} + * @param {string} content any text + * @returns {string} ex: "Wild Gengar fainted!", "Ectoplasma sauvage est K.O!" + * @see {@linkcode getPokemonNameWithAffix} for the Pokemon's name and potentiel affix + */ export function getPokemonMessage(pokemon: Pokemon, content: string): string { - return `${getPokemonPrefix(pokemon)}${pokemon.name}${content}`; + return `${getPokemonNameWithAffix(pokemon)}${content}`; } -export function getPokemonPrefix(pokemon: Pokemon): string { - let prefix: string; +/** + * Retrieves the Pokemon's name, potentially with an affix indicating its role (wild or foe) in the current battle context, translated + * @param pokemon {@linkcode Pokemon} name and battle context will be retrieved from this instance + * @returns {string} ex: "Wild Gengar", "Ectoplasma sauvage" + */ +export function getPokemonNameWithAffix(pokemon: Pokemon): string { switch (pokemon.scene.currentBattle.battleSpec) { case BattleSpec.DEFAULT: - prefix = !pokemon.isPlayer() ? pokemon.hasTrainer() ? "Foe " : "Wild " : ""; - break; + return !pokemon.isPlayer() + ? pokemon.hasTrainer() + ? i18next.t("battle:foePokemonWithAffix", { + pokemonName: pokemon.name, + }) + : i18next.t("battle:wildPokemonWithAffix", { + pokemonName: pokemon.name, + }) + : pokemon.name; case BattleSpec.FINAL_BOSS: - prefix = !pokemon.isPlayer() ? "Foe " : ""; - break; + return !pokemon.isPlayer() + ? i18next.t("battle:foePokemonWithAffix", { pokemonName: pokemon.name }) + : pokemon.name; + default: + return pokemon.name; } - return prefix; } diff --git a/src/phases.ts b/src/phases.ts index e9becbe485d..45acc79ca01 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -23,7 +23,7 @@ import { FusePokemonModifierType, ModifierPoolType, ModifierType, ModifierTypeFu import SoundFade from "phaser3-rex-plugins/plugins/soundfade"; import { BattlerTagLapseType, EncoreTag, HideSpriteTag as HiddenTag, ProtectedTag, TrappedTag } from "./data/battler-tags"; import { BattlerTagType } from "./data/enums/battler-tag-type"; -import { getPokemonMessage, getPokemonPrefix } from "./messages"; +import { getPokemonMessage, getPokemonNameWithAffix } from "./messages"; import { Starter } from "./ui/starter-select-ui-handler"; import { Gender } from "./data/gender"; import { Weather, WeatherType, getRandomWeatherType, getTerrainBlockMessage, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather"; @@ -2276,7 +2276,7 @@ export class TurnEndPhase extends FieldPhase { pokemon.lapseTags(BattlerTagLapseType.TURN_END); if (pokemon.summonData.disabledMove && !--pokemon.summonData.disabledTurns) { - this.scene.pushPhase(new MessagePhase(this.scene, i18next.t("battle:notDisabled", { pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, moveName: allMoves[pokemon.summonData.disabledMove].name }))); + this.scene.pushPhase(new MessagePhase(this.scene, i18next.t("battle:notDisabled", { pokemonName: getPokemonNameWithAffix(pokemon), moveName: allMoves[pokemon.summonData.disabledMove].name }))); pokemon.summonData.disabledMove = Moves.NONE; } @@ -2643,7 +2643,10 @@ export class MovePhase extends BattlePhase { if (this.move.getMove().hasAttr(ChargeAttr)) { const lastMove = this.pokemon.getLastXMoves() as TurnMove[]; if (!lastMove.length || lastMove[0].move !== this.move.getMove().id || lastMove[0].result !== MoveResult.OTHER) { - this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500); + this.scene.queueMessage(i18next.t("battle:useMove", { + pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon), + moveName: this.move.getName() + }), 500); return; } } @@ -2652,7 +2655,10 @@ export class MovePhase extends BattlePhase { return; } - this.scene.queueMessage(getPokemonMessage(this.pokemon, ` used\n${this.move.getName()}!`), 500); + this.scene.queueMessage(i18next.t("battle:useMove", { + pokemonNameWithAffix: getPokemonNameWithAffix(this.pokemon), + moveName: this.move.getName() + }), 500); applyMoveAttrs(PreMoveMessageAttr, this.pokemon, this.pokemon.getOpponents().find(() => true), this.move.getMove()); }