diff --git a/assets/js/critical/languageSelector.js b/assets/js/critical/languageSelector.js index 89ffbb973..f6b900882 100644 --- a/assets/js/critical/languageSelector.js +++ b/assets/js/critical/languageSelector.js @@ -45,7 +45,7 @@ // continue with regular code const storedLanguage = getLanguage() - const languageItems = document.querySelectorAll('#language-selector .dropdown-item') + const languageItems = document.querySelectorAll('#language-selector[data-translated=true] .dropdown-item') const link = document.querySelector("link[rel='canonical']") let alias = '' @@ -77,13 +77,8 @@ }) } else { - // Redirect to the localized homepage - const defaultLang = '{{ site.LanguageCode | default site.Language.Lang }}' - let language = storedLanguage ? storedLanguage : defaultLang - let target = folder + language + '/' - if (window.location.href !== target) { - window.location.href = target - } + // overrule the current stored language when no translation is available + setLanguage(document.documentElement.lang) } }) })() diff --git a/layouts/partials/assets/navbar.html b/layouts/partials/assets/navbar.html index 9102a16b3..d8678436d 100644 --- a/layouts/partials/assets/navbar.html +++ b/layouts/partials/assets/navbar.html @@ -269,7 +269,7 @@ {{- partial "assets/icon.html" (dict "icon" "fas globe fa-fw" "spacing" false) }} -