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 { 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,12 +982,9 @@ 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 genderedPool = trainerTypePool[randInt(trainerTypePool.length)];
const trainerNameString = Array.isArray(genderedPool) ? genderedPool[randInt(genderedPool.length)] : genderedPool; 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 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,8 +60,8 @@ 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 }) as any;
this.name = this.name =
name || name ||
Utils.randSeedItem(Array.isArray(namePool[0]) ? namePool[variant === TrainerVariant.FEMALE ? 1 : 0] : namePool); 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", "terrain",
"titles", "titles",
"trainerClasses", "trainerClasses",
"trainersCommon",
"trainerNames", "trainerNames",
"tutorial", "tutorial",
"voucher", "voucher",