Skip to content

Commit

Permalink
GN-4808: Fix language detection for users that are coming to GN for t…
Browse files Browse the repository at this point in the history
…he first time
  • Loading branch information
dkozickis committed Apr 22, 2024
1 parent 59e6108 commit 862e558
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-worms-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frontend-gelinkt-notuleren": patch
---

GN-4808: Fix language detection for users that are coming to GN for the first time
16 changes: 14 additions & 2 deletions app/utils/intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,21 @@ export function decentLocaleMatch(
);

const deduplicatedSupportedLocales = new Set([
...supportedLocalesThatUserPrefers.map((locale) => locale.toLowerCase()),
...supportedLocalesThatUserPrefers.map(
(locale) => locale && locale.toLowerCase(),
),
defaultLocale.toLowerCase(),
]);

return [...deduplicatedSupportedLocales];
const definedSupportedLocales = [...deduplicatedSupportedLocales].filter(
(locale) => typeof locale === 'string',
);

const lowerCaseDefaultLocale = defaultLocale.toLowerCase();

if (definedSupportedLocales.length < 1) {
return [lowerCaseDefaultLocale];
}

return [...definedSupportedLocales, lowerCaseDefaultLocale];
}

0 comments on commit 862e558

Please sign in to comment.