From 1514e5aa6e521501916a3bb20a859934ecf0d098 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 20 Aug 2025 22:25:23 -0400 Subject: [PATCH 01/10] [Dev] Ensure `i18n` module is initialized immediately when imported --- src/data/trainers/trainer-config.ts | 58 +--- src/field/trainer.ts | 6 - src/init/init.ts | 4 +- src/main.ts | 5 +- src/plugins/i18n.ts | 350 ++++++++++---------- test/test-utils/test-file-initialization.ts | 13 +- test/vitest.setup.ts | 2 + 7 files changed, 180 insertions(+), 258 deletions(-) diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index f0042e0af91..0dd693bcb69 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -20,7 +20,6 @@ import { TrainerType } from "#enums/trainer-type"; import { TrainerVariant } from "#enums/trainer-variant"; import type { EnemyPokemon } from "#field/pokemon"; import { PokemonMove } from "#moves/pokemon-move"; -import { getIsInitialized, initI18n } from "#plugins/i18n"; import type { EvilTeam } from "#trainers/evil-admin-trainer-pools"; import { evilAdminTrainerPools } from "#trainers/evil-admin-trainer-pools"; import { @@ -164,13 +163,10 @@ export class TrainerConfig { setName(name: string): TrainerConfig { if (name === "Finn") { // Give the rival a localized name - // First check if i18n is initialized - if (!getIsInitialized()) { - initI18n(); - } // This is only the male name, because the female name is handled in a different function (setHasGenders) - if (name === "Finn") { - name = i18next.t("trainerNames:rival"); + name = i18next.t("trainerNames:rival"); + if (!name) { + throw new Error("skibidi sigma"); } } @@ -188,11 +184,6 @@ export class TrainerConfig { } setTitle(title: string): TrainerConfig { - // First check if i18n is initialized - if (!getIsInitialized()) { - initI18n(); - } - title = toCamelCase(title); // Get the title from the i18n file @@ -281,11 +272,6 @@ export class TrainerConfig { setHasGenders(nameFemale?: string, femaleEncounterBgm?: TrainerType | string): TrainerConfig { // If the female name is 'Ivy' (the rival), assign a localized name. if (nameFemale === "Ivy") { - // Check if the internationalization (i18n) system is initialized. - if (!getIsInitialized()) { - // Initialize the i18n system if it is not already initialized. - initI18n(); - } // Set the localized name for the female rival. this.nameFemale = i18next.t("trainerNames:rivalFemale"); } else { @@ -359,11 +345,6 @@ export class TrainerConfig { * @returns {TrainerConfig} The updated TrainerConfig instance. */ setDoubleTitle(titleDouble: string): TrainerConfig { - // First check if i18n is initialized - if (!getIsInitialized()) { - initI18n(); - } - titleDouble = toCamelCase(titleDouble); // Get the title from the i18n file @@ -533,10 +514,6 @@ export class TrainerConfig { signatureSpecies: (SpeciesId | SpeciesId[])[], specialtyType?: PokemonType, ): TrainerConfig { - if (!getIsInitialized()) { - initI18n(); - } - if (!isNullOrUndefined(specialtyType)) { this.setSpecialtyType(specialtyType); } @@ -569,10 +546,6 @@ export class TrainerConfig { * @returns {TrainerConfig} The updated TrainerConfig instance. */ initForStatTrainer(_isMale = false): TrainerConfig { - if (!getIsInitialized()) { - initI18n(); - } - this.setPartyTemplates(trainerPartyTemplates.ELITE_FOUR); const nameForCall = toCamelCase(this.name); @@ -601,9 +574,6 @@ export class TrainerConfig { rematch = false, specialtyType?: PokemonType, ): TrainerConfig { - if (!getIsInitialized()) { - initI18n(); - } if (rematch) { this.setPartyTemplates(trainerPartyTemplates.ELITE_FOUR); } else { @@ -645,11 +615,6 @@ export class TrainerConfig { ignoreMinTeraWave = false, teraSlot?: number, ): TrainerConfig { - // Check if the internationalization (i18n) system is initialized. - if (!getIsInitialized()) { - initI18n(); - } - // Set the function to generate the Gym Leader's party template. this.setPartyTemplateFunc(getGymLeaderPartyTemplate); @@ -702,11 +667,6 @@ export class TrainerConfig { specialtyType?: PokemonType, teraSlot?: number, ): TrainerConfig { - // Check if the internationalization (i18n) system is initialized. - if (!getIsInitialized()) { - initI18n(); - } - // Set the party templates for the Elite Four. this.setPartyTemplates(trainerPartyTemplates.ELITE_FOUR); @@ -753,11 +713,6 @@ export class TrainerConfig { * @returns {TrainerConfig} The updated TrainerConfig instance. */ initForChampion(isMale: boolean): TrainerConfig { - // Check if the internationalization (i18n) system is initialized. - if (!getIsInitialized()) { - initI18n(); - } - // Set the party templates for the Champion. this.setPartyTemplates(trainerPartyTemplates.CHAMPION); @@ -788,10 +743,6 @@ export class TrainerConfig { * @returns {TrainerConfig} The updated TrainerConfig instance. */ setLocalizedName(name: string): TrainerConfig { - // Check if the internationalization (i18n) system is initialized. - if (!getIsInitialized()) { - initI18n(); - } this.name = i18next.t(`trainerNames:${toCamelCase(name)}`); return this; } @@ -824,9 +775,6 @@ export class TrainerConfig { } // Check if !variant is true, if so return the name, else return the name with _female appended else if (variant) { - if (!getIsInitialized()) { - initI18n(); - } // Check if the female version exists in the i18n file if (i18next.exists(`trainerClasses:${toCamelCase(this.name)}Female`)) { // If it does, return diff --git a/src/field/trainer.ts b/src/field/trainer.ts index acbc8031dbc..019d5f49723 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -13,7 +13,6 @@ import { TrainerType } from "#enums/trainer-type"; import { TrainerVariant } from "#enums/trainer-variant"; import type { EnemyPokemon } from "#field/pokemon"; import type { PersistentModifier } from "#modifiers/modifier"; -import { getIsInitialized, initI18n } from "#plugins/i18n"; import type { TrainerConfig } from "#trainers/trainer-config"; import { trainerConfigs } from "#trainers/trainer-config"; import { TrainerPartyCompoundTemplate, type TrainerPartyTemplate } from "#trainers/trainer-party-template"; @@ -176,11 +175,6 @@ export class Trainer extends Phaser.GameObjects.Container { if (this.name) { // If the title should be included. if (includeTitle) { - // Check if the internationalization (i18n) system is initialized. - if (!getIsInitialized()) { - // Initialize the i18n system if it is not already initialized. - initI18n(); - } // Get the localized trainer class name from the i18n file and set it as the title. // This is used for trainer class names, not titles like "Elite Four, Champion, etc." title = i18next.t(`trainerClasses:${toCamelCase(name)}`); diff --git a/src/init/init.ts b/src/init/init.ts index ba9738e2be8..7019edc58ed 100644 --- a/src/init/init.ts +++ b/src/init/init.ts @@ -14,7 +14,9 @@ import { initAchievements } from "#system/achv"; import { initVouchers } from "#system/voucher"; import { initStatsKeys } from "#ui/game-stats-ui-handler"; -/** Initialize the game. */ +/** + * Initialize various values at the beginning of each testing instance. + */ export function initializeGame() { initModifierTypes(); initModifierPools(); diff --git a/src/main.ts b/src/main.ts index 7e4943bdca5..0745d2b5abf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,9 @@ import "#app/polyfills"; // All polyfills MUST be loaded first for side effects +import "#app/plugins/i18n"; +// Initializes i18n on import import { InvertPostFX } from "#app/pipelines/invert"; -import { initI18n } from "#app/plugins/i18n"; import { version } from "#package.json"; import Phaser from "phaser"; import BBCodeTextPlugin from "phaser3-rex-plugins/plugins/bbcodetext-plugin"; @@ -49,7 +50,7 @@ let game; let manifest; const startGame = async () => { - await initI18n(); + await import("#plugins/i18n"); const LoadingScene = (await import("./loading-scene")).LoadingScene; const BattleScene = (await import("./battle-scene")).BattleScene; game = new Phaser.Game({ diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 62fc73a10a3..0a4af8298fe 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -3,7 +3,7 @@ import { toKebabCase } from "#utils/strings"; import i18next from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import HttpBackend from "i18next-http-backend"; -import processor, { KoreanPostpositionProcessor } from "i18next-korean-postposition-processor"; +import processor from "i18next-korean-postposition-processor"; //#region Interfaces/Types @@ -15,8 +15,6 @@ interface LoadingFontFaceProperty { //#region Constants -let isInitialized = false; - const unicodeRanges = { fullwidth: "U+FF00-FFEF", hangul: "U+1100-11FF,U+3130-318F,U+A960-A97F,U+AC00-D7AF,U+D7B0-D7FF", @@ -136,193 +134,179 @@ function i18nMoneyFormatter(amount: any): string { return `@[MONEY]{${i18next.t("common:money", { amount })}}`; } -//#region Exports +//#region Initialization /** - * Initialize i18n with fonts + * i18next is a localization library for maintaining and using translation resources. + * + * Q: How do I add a new language? + * A: To add a new language, create a new folder in the locales directory with the language code. + * Each language folder should contain a file for each namespace (ex. menu.ts) with the translations. + * Don't forget to declare new language in `supportedLngs` i18next initializer + * + * Q: How do I add a new namespace? + * A: To add a new namespace, create a new file in each language folder with the translations. + * Then update the config file for that language in its locale directory + * and the CustomTypeOptions interface in the @types/i18next.d.ts file. + * + * Q: How do I make a language selectable in the settings? + * A: In src/system/settings.ts, add a new case to the Setting.Language switch statement. */ -export async function initI18n(): Promise { - // Prevent reinitialization - if (isInitialized) { - return; - } - isInitialized = true; - /** - * i18next is a localization library for maintaining and using translation resources. - * - * Q: How do I add a new language? - * A: To add a new language, create a new folder in the locales directory with the language code. - * Each language folder should contain a file for each namespace (ex. menu.ts) with the translations. - * Don't forget to declare new language in `supportedLngs` i18next initializer - * - * Q: How do I add a new namespace? - * A: To add a new namespace, create a new file in each language folder with the translations. - * Then update the config file for that language in its locale directory - * and the CustomTypeOptions interface in the @types/i18next.d.ts file. - * - * Q: How do I make a language selectable in the settings? - * A: In src/system/settings.ts, add a new case to the Setting.Language switch statement. - */ - - i18next.use(HttpBackend); - i18next.use(LanguageDetector); - i18next.use(processor); - i18next.use(new KoreanPostpositionProcessor()); - await i18next.init({ - fallbackLng: { - "es-MX": ["es-ES", "en"], - default: ["en"], - }, - supportedLngs: [ - "en", - "es-ES", - "es-MX", - "fr", - "it", - "de", - "zh-CN", - "zh-TW", - "pt-BR", - "ko", - "ja", - "ca", - "da", - "tr", - "ro", - "ru", - "tl", - ], - backend: { - loadPath(lng: string, [ns]: string[]) { - // Use namespace maps where required - let fileName: string; - if (namespaceMap[ns]) { - fileName = namespaceMap[ns]; - } else if (ns.startsWith("mysteryEncounters/")) { - fileName = toKebabCase(ns + "-dialogue"); // mystery-encounters/a-trainers-test-dialogue - } else { - fileName = toKebabCase(ns); - } - // ex: "./locales/en/move-anims" - return `./locales/${lng}/${fileName}.json?v=${pkg.version}`; +i18next + .use(HttpBackend) + .use(LanguageDetector) + .use(processor) + .init( + { + fallbackLng: { + "es-MX": ["es-ES", "en"], + default: ["en"], }, + supportedLngs: [ + "en", + "es-ES", + "es-MX", + "fr", + "it", + "de", + "zh-CN", + "zh-TW", + "pt-BR", + "ko", + "ja", + "ca", + "da", + "tr", + "ro", + "ru", + ], + backend: { + loadPath(lng: string, [ns]: string[]) { + // Use namespace maps where required + let fileName: string; + if (namespaceMap[ns]) { + fileName = namespaceMap[ns]; + } else if (ns.startsWith("mysteryEncounters/")) { + fileName = toKebabCase(ns + "-dialogue"); // mystery-encounters/a-trainers-test-dialogue + } else { + fileName = toKebabCase(ns); + } + // ex: "./locales/en/move-anims" + return `./locales/${lng}/${fileName}.json?v=${pkg.version}`; + }, + }, + defaultNS: "menu", + ns: [ + "ability", + "abilityTriggers", + "arenaFlyout", + "arenaTag", + "battle", + "battleScene", + "battleInfo", + "battleMessageUiHandler", + "battlePokemonForm", + "battlerTags", + "berry", + "bgmName", + "biome", + "challenges", + "commandUiHandler", + "common", + "achv", + "dialogue", + "battleSpecDialogue", + "miscDialogue", + "doubleBattleDialogue", + "egg", + "fightUiHandler", + "filterBar", + "filterText", + "gameMode", + "gameStatsUiHandler", + "growth", + "menu", + "menuUiHandler", + "modifier", + "modifierType", + "move", + "nature", + "pokeball", + "pokedexUiHandler", + "pokemon", + "pokemonCategory", + "pokemonEvolutions", + "pokemonForm", + "pokemonInfo", + "pokemonInfoContainer", + "pokemonSummary", + "saveSlotSelectUiHandler", + "settings", + "splashMessages", + "starterSelectUiHandler", + "statusEffect", + "terrain", + "titles", + "trainerClasses", + "trainersCommon", + "trainerNames", + "tutorial", + "voucher", + "weather", + "partyUiHandler", + "modifierSelectUiHandler", + "moveTriggers", + "runHistory", + "mysteryEncounters/mysteriousChallengers", + "mysteryEncounters/mysteriousChest", + "mysteryEncounters/darkDeal", + "mysteryEncounters/fightOrFlight", + "mysteryEncounters/slumberingSnorlax", + "mysteryEncounters/trainingSession", + "mysteryEncounters/departmentStoreSale", + "mysteryEncounters/shadyVitaminDealer", + "mysteryEncounters/fieldTrip", + "mysteryEncounters/safariZone", + "mysteryEncounters/lostAtSea", + "mysteryEncounters/fieryFallout", + "mysteryEncounters/theStrongStuff", + "mysteryEncounters/thePokemonSalesman", + "mysteryEncounters/anOfferYouCantRefuse", + "mysteryEncounters/delibirdy", + "mysteryEncounters/absoluteAvarice", + "mysteryEncounters/aTrainersTest", + "mysteryEncounters/trashToTreasure", + "mysteryEncounters/berriesAbound", + "mysteryEncounters/clowningAround", + "mysteryEncounters/partTimer", + "mysteryEncounters/dancingLessons", + "mysteryEncounters/weirdDream", + "mysteryEncounters/theWinstrateChallenge", + "mysteryEncounters/teleportingHijinks", + "mysteryEncounters/bugTypeSuperfan", + "mysteryEncounters/funAndGames", + "mysteryEncounters/uncommonBreed", + "mysteryEncounters/globalTradeSystem", + "mysteryEncounters/theExpertPokemonBreeder", + "mysteryEncounterMessages", + ], + detection: { + lookupLocalStorage: "prLang", + }, + debug: Number(import.meta.env.VITE_I18N_DEBUG) === 1, + interpolation: { + escapeValue: false, + }, + postProcess: ["korean-postposition"], }, - defaultNS: "menu", - ns: [ - "ability", - "abilityTriggers", - "arenaFlyout", - "arenaTag", - "battle", - "battleScene", - "battleInfo", - "battleMessageUiHandler", - "battlePokemonForm", - "battlerTags", - "berry", - "bgmName", - "biome", - "challenges", - "commandUiHandler", - "common", - "achv", - "dialogue", - "battleSpecDialogue", - "miscDialogue", - "doubleBattleDialogue", - "egg", - "fightUiHandler", - "filterBar", - "filterText", - "gameMode", - "gameStatsUiHandler", - "growth", - "menu", - "menuUiHandler", - "modifier", - "modifierType", - "move", - "nature", - "pokeball", - "pokedexUiHandler", - "pokemon", - "pokemonCategory", - "pokemonEvolutions", - "pokemonForm", - "pokemonInfo", - "pokemonInfoContainer", - "pokemonSummary", - "saveSlotSelectUiHandler", - "settings", - "splashMessages", - "starterSelectUiHandler", - "statusEffect", - "terrain", - "titles", - "trainerClasses", - "trainersCommon", - "trainerNames", - "tutorial", - "voucher", - "weather", - "partyUiHandler", - "modifierSelectUiHandler", - "moveTriggers", - "runHistory", - "mysteryEncounters/mysteriousChallengers", - "mysteryEncounters/mysteriousChest", - "mysteryEncounters/darkDeal", - "mysteryEncounters/fightOrFlight", - "mysteryEncounters/slumberingSnorlax", - "mysteryEncounters/trainingSession", - "mysteryEncounters/departmentStoreSale", - "mysteryEncounters/shadyVitaminDealer", - "mysteryEncounters/fieldTrip", - "mysteryEncounters/safariZone", - "mysteryEncounters/lostAtSea", - "mysteryEncounters/fieryFallout", - "mysteryEncounters/theStrongStuff", - "mysteryEncounters/thePokemonSalesman", - "mysteryEncounters/anOfferYouCantRefuse", - "mysteryEncounters/delibirdy", - "mysteryEncounters/absoluteAvarice", - "mysteryEncounters/aTrainersTest", - "mysteryEncounters/trashToTreasure", - "mysteryEncounters/berriesAbound", - "mysteryEncounters/clowningAround", - "mysteryEncounters/partTimer", - "mysteryEncounters/dancingLessons", - "mysteryEncounters/weirdDream", - "mysteryEncounters/theWinstrateChallenge", - "mysteryEncounters/teleportingHijinks", - "mysteryEncounters/bugTypeSuperfan", - "mysteryEncounters/funAndGames", - "mysteryEncounters/uncommonBreed", - "mysteryEncounters/globalTradeSystem", - "mysteryEncounters/theExpertPokemonBreeder", - "mysteryEncounterMessages", - ], - detection: { - lookupLocalStorage: "prLang", + async () => { + if (i18next.services.formatter) { + i18next.services.formatter.add("money", i18nMoneyFormatter); + } + await initFonts(localStorage.getItem("prLang") ?? undefined); }, - debug: Number(import.meta.env.VITE_I18N_DEBUG) === 1, - interpolation: { - escapeValue: false, - }, - postProcess: ["korean-postposition"], - }); - - if (i18next.services.formatter) { - i18next.services.formatter.add("money", i18nMoneyFormatter); - } - - await initFonts(localStorage.getItem("prLang") ?? undefined); -} - -export function getIsInitialized(): boolean { - return isInitialized; -} + ); export default i18next; diff --git a/test/test-utils/test-file-initialization.ts b/test/test-utils/test-file-initialization.ts index 631d3f9146b..04186d674f0 100644 --- a/test/test-utils/test-file-initialization.ts +++ b/test/test-utils/test-file-initialization.ts @@ -1,6 +1,5 @@ import { SESSION_ID_COOKIE_NAME } from "#app/constants"; import { initializeGame } from "#app/init/init"; -import { initI18n } from "#plugins/i18n"; import { blobToString } from "#test/test-utils/game-manager-utils"; import { manageListeners } from "#test/test-utils/listeners-manager"; import { MockConsoleLog } from "#test/test-utils/mocks/mock-console-log"; @@ -15,26 +14,18 @@ import InputText from "phaser3-rex-plugins/plugins/inputtext"; let wasInitialized = false; /** - * Run initialization code upon starting a new file, both per-suite and per-instance oncess. + * Run initialization code upon starting a new file, both per-suite and per-instance ones. */ export function initTests(): void { setupStubs(); if (!wasInitialized) { - initTestFile(); + initializeGame(); wasInitialized = true; } manageListeners(); } -/** - * Initialize various values at the beginning of each testing instance. - */ -function initTestFile(): void { - initI18n(); - initializeGame(); -} - /** * Setup various stubs for testing. * @todo Move this into a dedicated stub file instead of running it once per test instance diff --git a/test/vitest.setup.ts b/test/vitest.setup.ts index be35e18e2e9..563694b85c7 100644 --- a/test/vitest.setup.ts +++ b/test/vitest.setup.ts @@ -1,4 +1,6 @@ import "vitest-canvas-mock"; +import "#plugins/i18n"; // Initializes i18n on import + import { initTests } from "#test/test-utils/test-file-initialization"; import { afterAll, beforeAll, vi } from "vitest"; From 0a2978182ce1cee2a3195235bd6dc9fd81ac69c3 Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Wed, 20 Aug 2025 22:44:57 -0400 Subject: [PATCH 02/10] Fixed missing await? --- src/plugins/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 0a4af8298fe..161bce6dc06 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -153,7 +153,7 @@ function i18nMoneyFormatter(amount: any): string { * A: In src/system/settings.ts, add a new case to the Setting.Language switch statement. */ -i18next +await i18next .use(HttpBackend) .use(LanguageDetector) .use(processor) From 822b504d6a09ebf80c14e019006ca33d8d292cb3 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Sun, 24 Aug 2025 18:11:11 -0400 Subject: [PATCH 03/10] Update src/main.ts --- src/main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 0745d2b5abf..4922f929adc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -50,7 +50,6 @@ let game; let manifest; const startGame = async () => { - await import("#plugins/i18n"); const LoadingScene = (await import("./loading-scene")).LoadingScene; const BattleScene = (await import("./battle-scene")).BattleScene; game = new Phaser.Game({ From 6f52792f05767090aa225f662d4fe08090363e69 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Sat, 6 Sep 2025 19:50:05 -0400 Subject: [PATCH 04/10] Update init.ts --- src/init/init.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/init/init.ts b/src/init/init.ts index 7019edc58ed..ba9738e2be8 100644 --- a/src/init/init.ts +++ b/src/init/init.ts @@ -14,9 +14,7 @@ import { initAchievements } from "#system/achv"; import { initVouchers } from "#system/voucher"; import { initStatsKeys } from "#ui/game-stats-ui-handler"; -/** - * Initialize various values at the beginning of each testing instance. - */ +/** Initialize the game. */ export function initializeGame() { initModifierTypes(); initModifierPools(); From ac4b94dc11d032a9376f858e50156cd1592a9d74 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Sat, 6 Sep 2025 19:50:18 -0400 Subject: [PATCH 05/10] Update src/main.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4922f929adc..154793c0ca0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ -import "#app/polyfills"; // All polyfills MUST be loaded first for side effects -import "#app/plugins/i18n"; +import "#app/polyfills"; // Initializes i18n on import +import "#app/plugins/i18n"; import { InvertPostFX } from "#app/pipelines/invert"; import { version } from "#package.json"; From cdeceb6144e49d4068ac3634d09e5c89396759b7 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Sat, 6 Sep 2025 19:51:05 -0400 Subject: [PATCH 06/10] Update src/plugins/i18n.ts --- src/plugins/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 161bce6dc06..f476d51004f 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -294,7 +294,7 @@ await i18next detection: { lookupLocalStorage: "prLang", }, - debug: Number(import.meta.env.VITE_I18N_DEBUG) === 1, + debug: import.meta.env.VITE_I18N_DEBUG === "1", interpolation: { escapeValue: false, }, From 9b5e4f95232f907a960d46cbb18bf7d70cd6acc1 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Sat, 6 Sep 2025 19:51:38 -0400 Subject: [PATCH 07/10] Update trainer-config.ts --- src/data/trainers/trainer-config.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index 0dd693bcb69..c11bcac1069 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -165,9 +165,6 @@ export class TrainerConfig { // Give the rival a localized name // This is only the male name, because the female name is handled in a different function (setHasGenders) name = i18next.t("trainerNames:rival"); - if (!name) { - throw new Error("skibidi sigma"); - } } this.name = name; From 2decc1d88e1fbcead9366234a44f1b2c6c9b133e Mon Sep 17 00:00:00 2001 From: Bertie690 Date: Tue, 9 Sep 2025 19:18:43 -0400 Subject: [PATCH 08/10] ran biome & made `@module` comment --- src/data/trainers/trainer-config.ts | 9 +++------ src/plugins/i18n.ts | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index cc0d5656e4c..16eb15f17e3 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -771,12 +771,9 @@ export class TrainerConfig { } } // Check if !variant is true, if so return the name, else return the name with _female appended - else if (variant) { - // Check if the female version exists in the i18n file - if (i18next.exists(`trainerClasses:${toCamelCase(this.name)}Female`)) { - // If it does, return - return ret + "Female"; - } + // Check if the female version exists in the i18n file + else if (variant && i18next.exists(`trainerClasses:${toCamelCase(this.name)}Female`)) { + return ret + "Female"; } } diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 03da1d66f5f..9cd70973e8e 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -137,6 +137,7 @@ function i18nMoneyFormatter(amount: any): string { //#region Initialization /** + * @module * i18next is a localization library for maintaining and using translation resources. * * Q: How do I add a new language? From 4e4610d661315ab385ef9d8e80a9dd56559b0424 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Tue, 16 Sep 2025 00:00:15 -0400 Subject: [PATCH 09/10] Update src/plugins/i18n.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/plugins/i18n.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 9cd70973e8e..03da1d66f5f 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -137,7 +137,6 @@ function i18nMoneyFormatter(amount: any): string { //#region Initialization /** - * @module * i18next is a localization library for maintaining and using translation resources. * * Q: How do I add a new language? From 8a450a4e410f6902b744c419efb8ba88d039f869 Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Tue, 16 Sep 2025 00:00:24 -0400 Subject: [PATCH 10/10] Update src/plugins/i18n.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/plugins/i18n.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 03da1d66f5f..27c194a8a8e 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -136,7 +136,7 @@ function i18nMoneyFormatter(amount: any): string { //#region Initialization -/** +/* * i18next is a localization library for maintaining and using translation resources. * * Q: How do I add a new language?