diff --git a/.changeset/strange-foxes-invent.md b/.changeset/strange-foxes-invent.md new file mode 100644 index 00000000000..532c354c3c6 --- /dev/null +++ b/.changeset/strange-foxes-invent.md @@ -0,0 +1,5 @@ +--- +"@wso2is/identity-apps-core": patch +--- + +Update the ui_locales resolving logic diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/branding-preferences.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/branding-preferences.jsp index 2863de919a6..45b75e90c75 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/branding-preferences.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/branding-preferences.jsp @@ -66,8 +66,17 @@ if (localeFromCookie != null) { lang = localeFromCookie; try { - String langStr = lang.split("_")[0]; - String langLocale = lang.split("_")[1]; + String langStr = "en"; + String langLocale = "US"; + + if (lang.contains("_")) { + langStr = lang.split("_")[0]; + langLocale = lang.split("_")[1]; + } else if (lang.contains("-")) { + langStr = lang.split("-")[0]; + langLocale = lang.split("-")[1]; + } + userLocale = new Locale(langStr, langLocale); } catch (Exception e) { // In case the language is defined but not in the correct format @@ -75,8 +84,17 @@ } } else if (uiLocaleFromURL != null) { for (String localeStr : uiLocaleFromURL.split(" ")) { - String langStr = localeStr.split("_")[0]; - String langLocale = localeStr.split("_")[1]; + String langStr = "en"; + String langLocale = "US"; + + if (lang.contains("_")) { + langStr = lang.split("_")[0]; + langLocale = lang.split("_")[1]; + } else if (lang.contains("-")) { + langStr = lang.split("-")[0]; + langLocale = lang.split("-")[1]; + } + Locale tempLocale = new Locale(langStr, langLocale); // Trying to find out whether we have a resource bundle for the given locale try { diff --git a/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/localize.jsp b/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/localize.jsp index 56a7e3187c9..850b1432a09 100644 --- a/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/localize.jsp +++ b/identity-apps-core/apps/authentication-portal/src/main/webapp/includes/localize.jsp @@ -49,8 +49,16 @@ lang = localeFromCookie; try { - String langStr = lang.split("_")[0]; - String langLocale = lang.split("_")[1]; + String langStr = "en"; + String langLocale = "US"; + + if (lang.contains("_")) { + langStr = lang.split("_")[0]; + langLocale = lang.split("_")[1]; + } else if (lang.contains("-")) { + langStr = lang.split("-")[0]; + langLocale = lang.split("-")[1]; + } userLocale = new Locale(langStr, langLocale); } catch (Exception e) { @@ -59,8 +67,16 @@ } } else if (uiLocaleFromURL != null) { for (String localeStr : uiLocaleFromURL.split(" ")) { - String langStr = localeStr.split("_")[0]; - String langLocale = localeStr.split("_")[1]; + String langStr = "en"; + String langLocale = "US"; + + if (localeStr.contains("_")) { + langStr = localeStr.split("_")[0]; + langLocale = localeStr.split("_")[1]; + } else if (localeStr.contains("-")) { + langStr = localeStr.split("-")[0]; + langLocale = localeStr.split("-")[1]; + } Locale tempLocale = new Locale(langStr, langLocale); diff --git a/identity-apps-core/apps/recovery-portal/src/main/webapp/includes/branding-preferences.jsp b/identity-apps-core/apps/recovery-portal/src/main/webapp/includes/branding-preferences.jsp index 54142a74b66..c4ed1addb38 100644 --- a/identity-apps-core/apps/recovery-portal/src/main/webapp/includes/branding-preferences.jsp +++ b/identity-apps-core/apps/recovery-portal/src/main/webapp/includes/branding-preferences.jsp @@ -66,8 +66,17 @@ if (localeFromCookie != null) { lang = localeFromCookie; try { - String langStr = lang.split("_")[0]; - String langLocale = lang.split("_")[1]; + String langStr = "en"; + String langLocale = "US"; + + if (lang.contains("_")) { + langStr = lang.split("_")[0]; + langLocale = lang.split("_")[1]; + } else if (lang.contains("-")) { + langStr = lang.split("-")[0]; + langLocale = lang.split("-")[1]; + } + userLocale = new Locale(langStr, langLocale); } catch (Exception e) { // In case the language is defined but not in the correct format @@ -75,8 +84,17 @@ } } else if (uiLocaleFromURL != null) { for (String localeStr : uiLocaleFromURL.split(" ")) { - String langStr = localeStr.split("_")[0]; - String langLocale = localeStr.split("_")[1]; + String langStr = "en"; + String langLocale = "US"; + + if (localeStr.contains("_")) { + langStr = localeStr.split("_")[0]; + langLocale = localeStr.split("_")[1]; + } else if (localeStr.contains("-")) { + langStr = localeStr.split("-")[0]; + langLocale = localeStr.split("-")[1]; + } + Locale tempLocale = new Locale(langStr, langLocale); // Trying to find out whether we have a resource bundle for the given locale try {