[P3] Fixing form name being incorrect for some evolved pokemon (#4742)

* Fixing form name being incorrect for some evolved pokemon

* Updated to include showing the root speciesId if the speciesId locale key doesn't exist
This commit is contained in:
Opaque02 2024-10-30 07:30:20 +10:00 committed by GitHub
parent 65269f935f
commit 1cbe8b1505
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -237,14 +237,20 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
const formKey = (pokemon.species?.forms?.[pokemon.formIndex!]?.formKey); const formKey = (pokemon.species?.forms?.[pokemon.formIndex!]?.formKey);
const formText = Utils.capitalizeString(formKey, "-", false, false) || ""; const formText = Utils.capitalizeString(formKey, "-", false, false) || "";
const speciesName = Utils.capitalizeString(Species[pokemon.species.getRootSpeciesId()], "_", true, false); const speciesName = Utils.capitalizeString(Species[pokemon.species.speciesId], "_", true, false);
let formName = ""; let formName = "";
if (pokemon.species.speciesId === Species.ARCEUS) { if (pokemon.species.speciesId === Species.ARCEUS) {
formName = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`); formName = i18next.t(`pokemonInfo:Type.${formText?.toUpperCase()}`);
} else { } else {
const i18key = `pokemonForm:${speciesName}${formText}`; const i18key = `pokemonForm:${speciesName}${formText}`;
formName = i18next.exists(i18key) ? i18next.t(i18key) : formText; if (i18next.exists(i18key)) {
formName = i18next.t(i18key);
} else {
const rootSpeciesName = Utils.capitalizeString(Species[pokemon.species.getRootSpeciesId()], "_", true, false);
const i18RootKey = `pokemonForm:${rootSpeciesName}${formText}`;
formName = i18next.exists(i18RootKey) ? i18next.t(i18RootKey) : formText;
}
} }
if (formName) { if (formName) {