Skip to content

Conversation

@htve
Copy link

@htve htve commented Jan 6, 2026

No description provided.

@1337LutZ
Copy link

1337LutZ commented Jan 7, 2026

@dodoels can you do a final check on this as you added the i18n feature initially 🙏

return lang;
};

const languageMap = new Map<string, string>([
Copy link

@dodoels dodoels Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to explictly define an utility function to do this which introduces extra complexity when we get rid of Wowhead in the future.

The existing languagedetector API from i18next-browser-languagedetector can already do the job.

Simply do

import LanguageDetector from 'i18next-browser-languagedetector';

export const detectBrowserLang = (): string => {
	const detector = new LanguageDetector();
	const detectedLang = detector.detect() as string;
	const baseLang = detectedLang.split('-')[0].toLowerCase();
	return baseLang in supportedLanguages ? baseLang : 'en'; // this is important, because we define what languages to support and compatible with Wowhead APIs
};

and finally just call this function in getLang()

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yea true!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants