Choose best language from the user browser#1281
Open
htve wants to merge 3 commits intowowsims:masterfrom
Open
Conversation
1337LutZ
reviewed
Jan 6, 2026
1337LutZ
reviewed
Jan 6, 2026
1337LutZ
reviewed
Jan 6, 2026
1337LutZ
reviewed
Jan 6, 2026
1337LutZ
reviewed
Jan 6, 2026
|
@dodoels can you do a final check on this as you added the i18n feature initially 🙏 |
dodoels
reviewed
Jan 7, 2026
| return lang; | ||
| }; | ||
|
|
||
| const languageMap = new Map<string, string>([ |
There was a problem hiding this comment.
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()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.