Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion ui/core/proto_utils/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<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=${getLangId()}`;
try {
const response = await fetch(url, { signal: options?.signal });
const json = await response.json();
Expand Down
21 changes: 21 additions & 0 deletions ui/i18n/locale_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ export const getLang = (): string => {
return setLang('en');
};

export const getLangId = (): number => {
Comment thread
htve marked this conversation as resolved.
Outdated
Comment thread
htve marked this conversation as resolved.
Outdated
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);
Expand Down