Skip to content

Commit

Permalink
LPS-132769 Set an attribute in request to build error forward redirec…
Browse files Browse the repository at this point in the history
…t using properly i18n locale.
  • Loading branch information
lfbesada authored and brianchandotcom committed Jun 23, 2021
1 parent bad87c0 commit d6b61ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions portal-impl/src/com/liferay/portal/servlet/I18nServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ protected I18nData getI18nData(HttpServletRequest httpServletRequest)

String path = GetterUtil.getString(httpServletRequest.getPathInfo());

Locale i18nLocale = LocaleUtil.fromLanguageId(i18nLanguageId);

String i18nPath = StringPool.SLASH + i18nLocale.toLanguageTag();

if (Validator.isNull(path)) {
path = "/";
}
Expand All @@ -178,6 +182,9 @@ protected I18nData getI18nData(HttpServletRequest httpServletRequest)
friendlyURL);

if (siteGroup == null) {
httpServletRequest.setAttribute(
WebKeys.I18N_ERROR_PATH, i18nPath);

return null;
}

Expand All @@ -186,10 +193,6 @@ protected I18nData getI18nData(HttpServletRequest httpServletRequest)
}
}

Locale i18nLocale = LocaleUtil.fromLanguageId(i18nLanguageId);

String i18nPath = StringPool.SLASH + i18nLocale.toLanguageTag();

if (siteDefaultLocale == null) {
if (PropsValues.LOCALE_USE_DEFAULT_IF_NOT_AVAILABLE) {
siteDefaultLocale = PortalUtil.getSiteDefaultLocale(siteGroup);
Expand Down
2 changes: 2 additions & 0 deletions portal-kernel/src/com/liferay/portal/kernel/util/WebKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ public interface WebKeys {

public static final String HTTPS_INITIAL = "HTTPS_INITIAL";

public static final String I18N_ERROR_PATH = "I18N_ERROR_PATH";

public static final String I18N_LANGUAGE_CODE = "I18N_LANGUAGE_CODE";

public static final String I18N_LANGUAGE_ID = "I18N_LANGUAGE_ID";
Expand Down

0 comments on commit d6b61ef

Please sign in to comment.