diff --git a/oidc-ui/src/App.js b/oidc-ui/src/App.js index 85e0ea635..8047013d9 100644 --- a/oidc-ui/src/App.js +++ b/oidc-ui/src/App.js @@ -78,7 +78,7 @@ function App() { //1. Check for ui locales param. Highest priority. //This will override the language detectors selected language - let supportedLanguages = loadLang.languages_2Letters; + let { languages_2Letters: supportedLanguages, langCodeMapping } = loadLang; let searchUrlParams = new URLSearchParams(window.location.search); let uiLocales = searchUrlParams.get("ui_locales"); if (uiLocales) { @@ -86,20 +86,29 @@ function App() { for (let idx in languages) { if (supportedLanguages[languages[idx]]) { i18n.changeLanguage(languages[idx]); - } else { - i18n.changeLanguage(window._env_.DEFAULT_LANG); + return; } } // if language code not found in 2 letter codes, then check mapped language codes - let langCodeMapping = loadLang.langCodeMapping; for (let idx in languages) { if (langCodeMapping[languages[idx]]) { i18n.changeLanguage(langCodeMapping[languages[idx]]); - } else { - i18n.changeLanguage(window._env_.DEFAULT_LANG); + return; } } + + let defaultLang = window._env_.DEFAULT_LANG; + // checking default language in 2 letter language code + if (defaultLang in supportedLanguages) { + i18n.changeLanguage(defaultLang) + return + } + // checking default language in 3 letter language code + if (defaultLang in langCodeMapping) { + i18n.changeLanguage(langCodeMapping[defaultLang]) + return + } } //2. Check for cookie @@ -117,7 +126,7 @@ function App() { case states.LOADING: el = (