From e642ca8e111155befc045299e61b85e1cda6af80 Mon Sep 17 00:00:00 2001 From: Celia Smitham Date: Tue, 6 Jan 2026 05:53:56 +0000 Subject: [PATCH 1/6] Add query parameter locale to Wowhead Tooltip url --- ui/core/proto_utils/database.ts | 3 ++- ui/i18n/locale_service.ts | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ui/core/proto_utils/database.ts b/ui/core/proto_utils/database.ts index f80becc117..b9e276b4c6 100644 --- a/ui/core/proto_utils/database.ts +++ b/ui/core/proto_utils/database.ts @@ -24,6 +24,7 @@ import { EquippedItem } from './equipped_item.js'; import { Gear, ItemSwapGear } from './gear.js'; import { gemEligibleForSocket, gemMatchesSocket } from './gems.js'; import { getEligibleEnchantSlots, getEligibleItemSlots } from './utils.js'; +import { getLangId } from '../../i18n/locale_service'; const dbUrlJson = '/mop/assets/database/db.json'; const dbUrlBin = '/mop/assets/database/db.bin'; @@ -400,7 +401,7 @@ export class Database { return Database.getWowheadTooltipData(id, 'spell', { signal: options?.signal }); } private static async getWowheadTooltipData(id: number, tooltipPostfix: string, options: { signal?: AbortSignal } = {}): Promise { - const url = `https://nether.wowhead.com/mop-classic/tooltip/${tooltipPostfix}/${id}?lvl=${CHARACTER_LEVEL}&dataEnv=${WOWHEAD_EXPANSION_ENV}`; + const url = `https://nether.wowhead.com/mop-classic/tooltip/${tooltipPostfix}/${id}?lvl=${CHARACTER_LEVEL}&dataEnv=${WOWHEAD_EXPANSION_ENV}&locale=${getLangId()}`; try { const response = await fetch(url, { signal: options?.signal }); const json = await response.json(); diff --git a/ui/i18n/locale_service.ts b/ui/i18n/locale_service.ts index 7be1464c21..7114b41458 100644 --- a/ui/i18n/locale_service.ts +++ b/ui/i18n/locale_service.ts @@ -16,6 +16,27 @@ export const getLang = (): string => { return setLang('en'); }; +export const getLangId = (): number => { + const storedLang = localStorage.getItem(STORAGE_KEY); + if (storedLang && storedLang in supportedLanguages) { + // Map language codes to numeric Ids, refer to Wowhead locale Ids + switch(storedLang) { + case 'ko': return 1; + case 'fr': return 2; + case 'de': return 3; + case 'cn': return 4; + case 'es': return 6; + case 'ru': return 7; + case 'pt': return 8; + case 'it': return 9; + case 'tw': return 10; + case 'mx': return 11; + default: return 0; + }; + } + return 0; +}; + export const setLang = (lang: string): string => { if (lang in supportedLanguages) { localStorage.setItem(STORAGE_KEY, lang); From cf31c791a8f9f2a412d4976044ed82c3ee9b5919 Mon Sep 17 00:00:00 2001 From: Celia Smitham Date: Tue, 6 Jan 2026 09:43:48 +0000 Subject: [PATCH 2/6] Migrate WoWHead language Id map to wowhead_locale_service.ts --- ui/i18n/locale_service.ts | 17 +++-------------- ui/i18n/wowhead_locale_service.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 ui/i18n/wowhead_locale_service.ts diff --git a/ui/i18n/locale_service.ts b/ui/i18n/locale_service.ts index 7114b41458..97997ded22 100644 --- a/ui/i18n/locale_service.ts +++ b/ui/i18n/locale_service.ts @@ -1,6 +1,8 @@ // Locale service for WoWSims // Single source of truth for language settings +import { getLangId as getWoWHeadLangId } from './wowhead_locale_service'; + const STORAGE_KEY = 'lang'; export const supportedLanguages: Record = { @@ -19,20 +21,7 @@ export const getLang = (): string => { export const getLangId = (): number => { const storedLang = localStorage.getItem(STORAGE_KEY); if (storedLang && storedLang in supportedLanguages) { - // Map language codes to numeric Ids, refer to Wowhead locale Ids - switch(storedLang) { - case 'ko': return 1; - case 'fr': return 2; - case 'de': return 3; - case 'cn': return 4; - case 'es': return 6; - case 'ru': return 7; - case 'pt': return 8; - case 'it': return 9; - case 'tw': return 10; - case 'mx': return 11; - default: return 0; - }; + return getWoWHeadLangId(storedLang); } return 0; }; diff --git a/ui/i18n/wowhead_locale_service.ts b/ui/i18n/wowhead_locale_service.ts new file mode 100644 index 0000000000..9b39f8bdfc --- /dev/null +++ b/ui/i18n/wowhead_locale_service.ts @@ -0,0 +1,16 @@ +// Map language codes to numeric Ids, refer to Wowhead locale Ids +export const getLangId = (code: string): number => { + switch(code) { + case 'ko': return 1; + case 'fr': return 2; + case 'de': return 3; + case 'cn': return 4; + case 'es': return 6; + case 'ru': return 7; + case 'pt': return 8; + case 'it': return 9; + case 'tw': return 10; + case 'mx': return 11; + default: return 0; + }; +}; \ No newline at end of file From 57275f65771977eafff8f03a97f60b0cad2f9969 Mon Sep 17 00:00:00 2001 From: Celia Smitham Date: Tue, 6 Jan 2026 09:47:19 +0000 Subject: [PATCH 3/6] Refactor the function to get wowhead lang id --- ui/i18n/wowhead_locale_service.ts | 33 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/ui/i18n/wowhead_locale_service.ts b/ui/i18n/wowhead_locale_service.ts index 9b39f8bdfc..3b75734c16 100644 --- a/ui/i18n/wowhead_locale_service.ts +++ b/ui/i18n/wowhead_locale_service.ts @@ -1,16 +1,21 @@ -// Map language codes to numeric Ids, refer to Wowhead locale Ids +const DEFAULT_LANG_ID = 0; + +//refer to Wowhead locale Ids +const LANG_ID_MAP: Record = { + ko: 1, + fr: 2, + de: 3, + cn: 4, + es: 6, + ru: 7, + pt: 8, + it: 9, + tw: 10, + mx: 11, +} as const; + +// Map language codes to numeric Id export const getLangId = (code: string): number => { - switch(code) { - case 'ko': return 1; - case 'fr': return 2; - case 'de': return 3; - case 'cn': return 4; - case 'es': return 6; - case 'ru': return 7; - case 'pt': return 8; - case 'it': return 9; - case 'tw': return 10; - case 'mx': return 11; - default: return 0; - }; + const normalized = code.toLowerCase(); + return LANG_ID_MAP[normalized] ?? DEFAULT_LANG_ID; }; \ No newline at end of file From 91367605283291b006f2d661eb5b0644419ad414 Mon Sep 17 00:00:00 2001 From: Celia Smitham Date: Tue, 6 Jan 2026 13:07:53 +0000 Subject: [PATCH 4/6] Migrate wowhead_locale_service.ts to wowhead.ts --- ui/core/wowhead.ts | 22 ++++++++++++++++++++++ ui/i18n/locale_service.ts | 4 ++-- ui/i18n/wowhead_locale_service.ts | 21 --------------------- 3 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 ui/i18n/wowhead_locale_service.ts diff --git a/ui/core/wowhead.ts b/ui/core/wowhead.ts index e0853fc5fc..072c5ba6ba 100644 --- a/ui/core/wowhead.ts +++ b/ui/core/wowhead.ts @@ -2,6 +2,22 @@ import { getLang } from '../i18n/locale_service'; import { CHARACTER_LEVEL } from './constants/mechanics'; import { Database } from './proto_utils/database'; +const DEFAULT_LANG_ID = 0; + +//refer to Wowhead locale Ids +const LANG_ID_MAP: Record = { + ko: 1, + fr: 2, + de: 3, + cn: 4, + es: 6, + ru: 7, + pt: 8, + it: 9, + tw: 10, + mx: 11, +} as const; + export type WowheadTooltipItemParams = { /** * @description Item ID @@ -142,3 +158,9 @@ export function getWowheadLanguagePrefix(): string { const lang = getLang(); return lang === 'en' ? '' : `${lang}/`; } + +// Map language code to numeric Id +export const getWowheadLanguageId = (lang: string): number => { + const normalized = lang.toLowerCase(); + return LANG_ID_MAP[normalized] ?? DEFAULT_LANG_ID; +}; diff --git a/ui/i18n/locale_service.ts b/ui/i18n/locale_service.ts index 97997ded22..4d48ccbed9 100644 --- a/ui/i18n/locale_service.ts +++ b/ui/i18n/locale_service.ts @@ -1,7 +1,7 @@ // Locale service for WoWSims // Single source of truth for language settings -import { getLangId as getWoWHeadLangId } from './wowhead_locale_service'; +import { getWowheadLanguageId } from '../core/wowhead'; const STORAGE_KEY = 'lang'; @@ -21,7 +21,7 @@ export const getLang = (): string => { export const getLangId = (): number => { const storedLang = localStorage.getItem(STORAGE_KEY); if (storedLang && storedLang in supportedLanguages) { - return getWoWHeadLangId(storedLang); + return getWowheadLanguageId(storedLang); } return 0; }; diff --git a/ui/i18n/wowhead_locale_service.ts b/ui/i18n/wowhead_locale_service.ts deleted file mode 100644 index 3b75734c16..0000000000 --- a/ui/i18n/wowhead_locale_service.ts +++ /dev/null @@ -1,21 +0,0 @@ -const DEFAULT_LANG_ID = 0; - -//refer to Wowhead locale Ids -const LANG_ID_MAP: Record = { - ko: 1, - fr: 2, - de: 3, - cn: 4, - es: 6, - ru: 7, - pt: 8, - it: 9, - tw: 10, - mx: 11, -} as const; - -// Map language codes to numeric Id -export const getLangId = (code: string): number => { - const normalized = code.toLowerCase(); - return LANG_ID_MAP[normalized] ?? DEFAULT_LANG_ID; -}; \ No newline at end of file From ec2f67e7987b9bba45208bfd820c86009cc5b38a Mon Sep 17 00:00:00 2001 From: Celia Smitham Date: Wed, 7 Jan 2026 09:58:34 +0000 Subject: [PATCH 5/6] Remove the dependencies in the Locale Service in the database --- ui/core/proto_utils/database.ts | 5 ++--- ui/core/wowhead.ts | 2 +- ui/i18n/locale_service.ts | 8 -------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/ui/core/proto_utils/database.ts b/ui/core/proto_utils/database.ts index b9e276b4c6..e511e4bdd5 100644 --- a/ui/core/proto_utils/database.ts +++ b/ui/core/proto_utils/database.ts @@ -19,12 +19,11 @@ import { Consumable, ItemEffectRandPropPoints, SimDatabase } from '../proto/db'; import { SpellEffect } from '../proto/spell'; import { GlyphID, IconData, UIDatabase, UIEnchant as Enchant, UIGem as Gem, UIItem as Item, UINPC as Npc, UIZone as Zone } from '../proto/ui.js'; import { distinct } from '../utils.js'; -import { WOWHEAD_EXPANSION_ENV } from '../wowhead'; +import { WOWHEAD_EXPANSION_ENV, getWowheadLanguageId } from '../wowhead'; import { EquippedItem } from './equipped_item.js'; import { Gear, ItemSwapGear } from './gear.js'; import { gemEligibleForSocket, gemMatchesSocket } from './gems.js'; import { getEligibleEnchantSlots, getEligibleItemSlots } from './utils.js'; -import { getLangId } from '../../i18n/locale_service'; const dbUrlJson = '/mop/assets/database/db.json'; const dbUrlBin = '/mop/assets/database/db.bin'; @@ -401,7 +400,7 @@ export class Database { return Database.getWowheadTooltipData(id, 'spell', { signal: options?.signal }); } private static async getWowheadTooltipData(id: number, tooltipPostfix: string, options: { signal?: AbortSignal } = {}): Promise { - const url = `https://nether.wowhead.com/mop-classic/tooltip/${tooltipPostfix}/${id}?lvl=${CHARACTER_LEVEL}&dataEnv=${WOWHEAD_EXPANSION_ENV}&locale=${getLangId()}`; + const url = `https://nether.wowhead.com/mop-classic/tooltip/${tooltipPostfix}/${id}?lvl=${CHARACTER_LEVEL}&dataEnv=${WOWHEAD_EXPANSION_ENV}&locale=${getWowheadLanguageId()}`; try { const response = await fetch(url, { signal: options?.signal }); const json = await response.json(); diff --git a/ui/core/wowhead.ts b/ui/core/wowhead.ts index 072c5ba6ba..1f62797395 100644 --- a/ui/core/wowhead.ts +++ b/ui/core/wowhead.ts @@ -160,7 +160,7 @@ export function getWowheadLanguagePrefix(): string { } // Map language code to numeric Id -export const getWowheadLanguageId = (lang: string): number => { +export const getWowheadLanguageId = (lang: string = getLang()): number => { const normalized = lang.toLowerCase(); return LANG_ID_MAP[normalized] ?? DEFAULT_LANG_ID; }; diff --git a/ui/i18n/locale_service.ts b/ui/i18n/locale_service.ts index 4d48ccbed9..fb16dcf359 100644 --- a/ui/i18n/locale_service.ts +++ b/ui/i18n/locale_service.ts @@ -18,14 +18,6 @@ export const getLang = (): string => { return setLang('en'); }; -export const getLangId = (): number => { - const storedLang = localStorage.getItem(STORAGE_KEY); - if (storedLang && storedLang in supportedLanguages) { - return getWowheadLanguageId(storedLang); - } - return 0; -}; - export const setLang = (lang: string): string => { if (lang in supportedLanguages) { localStorage.setItem(STORAGE_KEY, lang); From 27f63b1a9d10e830b66429fc6105b234c76fc9c5 Mon Sep 17 00:00:00 2001 From: Celia Smitham Date: Wed, 7 Jan 2026 10:14:50 +0000 Subject: [PATCH 6/6] Remove unused import from wowhead --- ui/i18n/locale_service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/i18n/locale_service.ts b/ui/i18n/locale_service.ts index fb16dcf359..7be1464c21 100644 --- a/ui/i18n/locale_service.ts +++ b/ui/i18n/locale_service.ts @@ -1,8 +1,6 @@ // Locale service for WoWSims // Single source of truth for language settings -import { getWowheadLanguageId } from '../core/wowhead'; - const STORAGE_KEY = 'lang'; export const supportedLanguages: Record = {