mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
Fix locale resolver issue with the languange.
This commit is contained in:
parent
e2682108e0
commit
46831e110b
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user