Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/core/proto_utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<IconData> {
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();
Expand Down
22 changes: 22 additions & 0 deletions ui/core/wowhead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, number> = {
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
Expand Down Expand Up @@ -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;
};