Skip to content

Commit

Permalink
Fix auto-detect lang check
Browse files Browse the repository at this point in the history
  • Loading branch information
jlau0170 committed Aug 7, 2024
1 parent a0eb07c commit 7420f58
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ms-store-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class MSStoreBadge extends HTMLElement {

static getSupportedLanguageFromUserAgent(): SupportedLanguage {
// Is the navigator language one of our supported languages? If so, use that.
const navigatorLanguage = MSStoreBadge.supportedLanguages.find(l => l.name === navigator.language);
const navigatorLanguage = MSStoreBadge.supportedLanguages.find(l => l.code === navigator.language.toLowerCase());
if (navigatorLanguage) {
return navigatorLanguage;
}
Expand All @@ -292,7 +292,7 @@ class MSStoreBadge extends HTMLElement {
// See if any of the navigator languages are supported.
if (navigator.languages) {
var match = navigator.languages
.map(lang => MSStoreBadge.supportedLanguages.find(l => l.code === lang))
.map(lang => MSStoreBadge.supportedLanguages.find(l => l.code === lang.toLowerCase()))
.find(l => !!l);
if (match) {
return match;
Expand All @@ -304,7 +304,7 @@ class MSStoreBadge extends HTMLElement {
const dashIndex = navigator.language.indexOf("-");
if (dashIndex > 0) {
const languageOnly = navigator.language.substring(0, dashIndex);
const supportedLanguage = MSStoreBadge.supportedLanguages.find(l => l.name === languageOnly);
const supportedLanguage = MSStoreBadge.supportedLanguages.find(l => l.code === languageOnly.toLowerCase());
if (supportedLanguage) {
return supportedLanguage;
}
Expand Down

0 comments on commit 7420f58

Please sign in to comment.