diff --git a/ui/core/proto_utils/database.ts b/ui/core/proto_utils/database.ts index f80becc117..e511e4bdd5 100644 --- a/ui/core/proto_utils/database.ts +++ b/ui/core/proto_utils/database.ts @@ -19,7 +19,7 @@ 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'; @@ -400,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}`; + 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 e0853fc5fc..1f62797395 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 = getLang()): number => { + const normalized = lang.toLowerCase(); + return LANG_ID_MAP[normalized] ?? DEFAULT_LANG_ID; +};