mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-04-22 01:24:13 +01:00
[Misc] Allow Localization of Common Trainer Names (#5569)
* Localize common trainer names * Update locale key usage
This commit is contained in:
parent
f09c77c81b
commit
b838d5f775
@ -23,7 +23,7 @@ import { allSpecies, getPokemonSpecies } from "#app/data/pokemon-species";
|
|||||||
import { getTypeRgb } from "#app/data/type";
|
import { getTypeRgb } from "#app/data/type";
|
||||||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||||
import { NumberHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle } from "#app/utils";
|
import { NumberHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle, randSeedItem } from "#app/utils";
|
||||||
import type { PlayerPokemon } from "#app/field/pokemon";
|
import type { PlayerPokemon } from "#app/field/pokemon";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { EnemyPokemon, PokemonMove } from "#app/field/pokemon";
|
import { EnemyPokemon, PokemonMove } from "#app/field/pokemon";
|
||||||
@ -41,11 +41,11 @@ import { Gender, getGenderSymbol } from "#app/data/gender";
|
|||||||
import { getNatureName } from "#app/data/nature";
|
import { getNatureName } from "#app/data/nature";
|
||||||
import { getPokeballAtlasKey, getPokeballTintColor } from "#app/data/pokeball";
|
import { getPokeballAtlasKey, getPokeballTintColor } from "#app/data/pokeball";
|
||||||
import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
import { getEncounterText, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||||
import { trainerNamePools } from "#app/data/trainer-names";
|
|
||||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/game-mode";
|
||||||
import { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
import { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
|
||||||
import type { PokeballType } from "#enums/pokeball";
|
import type { PokeballType } from "#enums/pokeball";
|
||||||
import { doShinySparkleAnim } from "#app/field/anims";
|
import { doShinySparkleAnim } from "#app/field/anims";
|
||||||
|
import { TrainerType } from "#enums/trainer-type";
|
||||||
|
|
||||||
/** the i18n namespace for the encounter */
|
/** the i18n namespace for the encounter */
|
||||||
const namespace = "mysteryEncounters/globalTradeSystem";
|
const namespace = "mysteryEncounters/globalTradeSystem";
|
||||||
@ -982,15 +982,14 @@ function doTradeReceivedSequence(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateRandomTraderName() {
|
function generateRandomTraderName() {
|
||||||
const length = Object.keys(trainerNamePools).length;
|
const length = TrainerType.YOUNGSTER - TrainerType.ACE_TRAINER + 1;
|
||||||
// +1 avoids TrainerType.UNKNOWN
|
// +1 avoids TrainerType.UNKNOWN
|
||||||
let trainerTypePool = trainerNamePools[randInt(length) + 1];
|
const trainerTypePool = i18next.t("trainersCommon:" + TrainerType[randInt(length) + 1], { returnObjects: true });
|
||||||
while (!trainerTypePool) {
|
|
||||||
trainerTypePool = trainerNamePools[randInt(length) + 1];
|
|
||||||
}
|
|
||||||
// Some trainers have 2 gendered pools, some do not
|
// Some trainers have 2 gendered pools, some do not
|
||||||
const genderedPool = trainerTypePool[randInt(trainerTypePool.length)];
|
const gender = randInt(2) === 0 ? "MALE" : "FEMALE";
|
||||||
const trainerNameString = Array.isArray(genderedPool) ? genderedPool[randInt(genderedPool.length)] : genderedPool;
|
const trainerNameString = randSeedItem(
|
||||||
|
Object.values(trainerTypePool.hasOwnProperty(gender) ? trainerTypePool[gender] : trainerTypePool),
|
||||||
|
) as string;
|
||||||
// Some names have an '&' symbol and need to be trimmed to a single name instead of a double name
|
// Some names have an '&' symbol and need to be trimmed to a single name instead of a double name
|
||||||
const trainerNames = trainerNameString.split(" & ");
|
const trainerNames = trainerNameString.split(" & ");
|
||||||
return trainerNames[randInt(trainerNames.length)];
|
return trainerNames[randInt(trainerNames.length)];
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,6 @@ import {
|
|||||||
import type { EnemyPokemon } from "#app/field/pokemon";
|
import type { EnemyPokemon } from "#app/field/pokemon";
|
||||||
import * as Utils from "#app/utils";
|
import * as Utils from "#app/utils";
|
||||||
import type { PersistentModifier } from "#app/modifier/modifier";
|
import type { PersistentModifier } from "#app/modifier/modifier";
|
||||||
import { trainerNamePools } from "#app/data/trainer-names";
|
|
||||||
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
|
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
|
||||||
import { getIsInitialized, initI18n } from "#app/plugins/i18n";
|
import { getIsInitialized, initI18n } from "#app/plugins/i18n";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
@ -61,11 +60,17 @@ export default class Trainer extends Phaser.GameObjects.Container {
|
|||||||
: Utils.randSeedWeightedItem(this.config.partyTemplates.map((_, i) => i)),
|
: Utils.randSeedWeightedItem(this.config.partyTemplates.map((_, i) => i)),
|
||||||
this.config.partyTemplates.length - 1,
|
this.config.partyTemplates.length - 1,
|
||||||
);
|
);
|
||||||
if (trainerNamePools.hasOwnProperty(trainerType)) {
|
if (i18next.exists("trainersCommon:" + TrainerType[trainerType], { returnObjects: true })) {
|
||||||
const namePool = trainerNamePools[trainerType];
|
const namePool = i18next.t("trainersCommon:" + TrainerType[trainerType], { returnObjects: true });
|
||||||
this.name =
|
this.name =
|
||||||
name ||
|
name ||
|
||||||
Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[variant === TrainerVariant.FEMALE ? 1 : 0] : namePool);
|
Utils.randSeedItem(
|
||||||
|
Object.values(
|
||||||
|
namePool.hasOwnProperty("MALE")
|
||||||
|
? namePool[variant === TrainerVariant.FEMALE ? "FEMALE" : "MALE"]
|
||||||
|
: namePool,
|
||||||
|
),
|
||||||
|
);
|
||||||
if (variant === TrainerVariant.DOUBLE) {
|
if (variant === TrainerVariant.DOUBLE) {
|
||||||
if (this.config.doubleOnly) {
|
if (this.config.doubleOnly) {
|
||||||
if (partnerName) {
|
if (partnerName) {
|
||||||
@ -74,7 +79,9 @@ export default class Trainer extends Phaser.GameObjects.Container {
|
|||||||
[this.name, this.partnerName] = this.name.split(" & ");
|
[this.name, this.partnerName] = this.name.split(" & ");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.partnerName = partnerName || Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[1] : namePool);
|
this.partnerName =
|
||||||
|
partnerName ||
|
||||||
|
Utils.randSeedItem(Object.values(namePool.hasOwnProperty("FEMALE") ? namePool["FEMALE"] : namePool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,6 +237,7 @@ export async function initI18n(): Promise<void> {
|
|||||||
"terrain",
|
"terrain",
|
||||||
"titles",
|
"titles",
|
||||||
"trainerClasses",
|
"trainerClasses",
|
||||||
|
"trainersCommon",
|
||||||
"trainerNames",
|
"trainerNames",
|
||||||
"tutorial",
|
"tutorial",
|
||||||
"voucher",
|
"voucher",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user