From 46831e110b18f3bbe94d35775edea3883a353e01 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 23 Aug 2012 23:55:26 -0300 Subject: [PATCH] Fix locale resolver issue with the languange. --- .../com/wisemapping/filter/UserLocaleInterceptor.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java index 5e7019cd..74728218 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java @@ -34,8 +34,6 @@ import java.util.Locale; public class UserLocaleInterceptor extends HandlerInterceptorAdapter { - public static final String USER_LOCALE = "user.locale"; - public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, Object object) throws Exception { final HttpSession session = request.getSession(false); @@ -45,7 +43,14 @@ public class UserLocaleInterceptor extends HandlerInterceptorAdapter { String userLocale = user.getLocale(); final Locale sessionLocale = (Locale) session.getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME); if ((userLocale != null) && ((sessionLocale == null) || (!userLocale.equals(sessionLocale.toString())))) { - session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale(userLocale)); + Locale locale; + if (userLocale.contains("_")) { + final String[] spit = userLocale.split("_"); + locale = new Locale(spit[0], spit[1]); + } else { + locale = new Locale(userLocale); + } + session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, locale); } } return true;