Localize common trainer names

This commit is contained in:
Dean 2025-03-28 02:15:12 -07:00
parent d955051730
commit 9a435552c4
4 changed files with 6 additions and 2654 deletions

View File

@ -41,11 +41,11 @@ import { Gender, getGenderSymbol } from "#app/data/gender";
import { getNatureName } from "#app/data/nature";
import { getPokeballAtlasKey, getPokeballTintColor } from "#app/data/pokeball";
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 { addPokemonDataToDexAndValidateAchievements } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils";
import type { PokeballType } from "#enums/pokeball";
import { doShinySparkleAnim } from "#app/field/anims";
import { TrainerType } from "#enums/trainer-type";
/** the i18n namespace for the encounter */
const namespace = "mysteryEncounters/globalTradeSystem";
@ -982,12 +982,9 @@ function doTradeReceivedSequence(
}
function generateRandomTraderName() {
const length = Object.keys(trainerNamePools).length;
const length = TrainerType.YOUNGSTER - TrainerType.ACE_TRAINER + 1;
// +1 avoids TrainerType.UNKNOWN
let trainerTypePool = trainerNamePools[randInt(length) + 1];
while (!trainerTypePool) {
trainerTypePool = trainerNamePools[randInt(length) + 1];
}
const trainerTypePool = i18next.t("trainersCommon:" + TrainerType[randInt(length) + 1], { returnObjects: true });
// Some trainers have 2 gendered pools, some do not
const genderedPool = trainerTypePool[randInt(trainerTypePool.length)];
const trainerNameString = Array.isArray(genderedPool) ? genderedPool[randInt(genderedPool.length)] : genderedPool;

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@ import {
import type { EnemyPokemon } from "#app/field/pokemon";
import * as Utils from "#app/utils";
import type { PersistentModifier } from "#app/modifier/modifier";
import { trainerNamePools } from "#app/data/trainer-names";
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
import { getIsInitialized, initI18n } from "#app/plugins/i18n";
import i18next from "i18next";
@ -61,8 +60,8 @@ export default class Trainer extends Phaser.GameObjects.Container {
: Utils.randSeedWeightedItem(this.config.partyTemplates.map((_, i) => i)),
this.config.partyTemplates.length - 1,
);
if (trainerNamePools.hasOwnProperty(trainerType)) {
const namePool = trainerNamePools[trainerType];
if (i18next.exists("trainersCommon:" + TrainerType[trainerType], { returnObjects: true })) {
const namePool = i18next.t("trainersCommon:" + TrainerType[trainerType], { returnObjects: true }) as any;
this.name =
name ||
Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[variant === TrainerVariant.FEMALE ? 1 : 0] : namePool);

View File

@ -237,6 +237,7 @@ export async function initI18n(): Promise<void> {
"terrain",
"titles",
"trainerClasses",
"trainersCommon",
"trainerNames",
"tutorial",
"voucher",