Skip to content

Commit

Permalink
Merge pull request #579 from Esri/rslibed/language-switcher-util
Browse files Browse the repository at this point in the history
Langauge Switcher: util fix
  • Loading branch information
rslibed authored Nov 8, 2024
2 parents 887865f + e733f9b commit 1e0df97
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prefersRTL, setLocale } from "esri/intl";
import { prefersRTL, setLocale, normalizeMessageBundleLocale } from "esri/intl";

import {
setPageDirection,
Expand All @@ -23,11 +23,12 @@ import {
// Determines default locale based on portal or locale url param
export function getDefaultLocale(portal: __esri.Portal, data: LanguageData) {
const defaultLanguage = calculateDefaultLocaleFromPortal(portal);
const defaultLocaleCode = normalizeMessageBundleLocale(defaultLanguage);
const urlObj = new URL(window.location.href);
const localeUrlParam = urlObj.searchParams.get("locale");
const useDefault =
(data?.locale === defaultLanguage || data === null || data === undefined) &&
!localeUrlParam;
(defaultLocaleCode === localeUrlParam || !localeUrlParam);
return useDefault ? defaultLanguage : null;
}

Expand Down

0 comments on commit 1e0df97

Please sign in to comment.