From 43aa3e2aea01c3a6ed34cfedfd58d2339f9b2234 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 30 Jun 2012 02:56:18 -0300 Subject: [PATCH] Fix change locale. --- wise-editor/src/main/webapp/css/embedded.less | 15 ++++++++------- .../wisemapping/filter/UserLocaleInterceptor.java | 13 +++---------- .../webapp/WEB-INF/classes/messages_es.properties | 1 + .../main/webapp/WEB-INF/wisemapping-servlet.xml | 4 +--- wise-webapp/src/main/webapp/jsp/errorTemplate.jsp | 3 +++ 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/wise-editor/src/main/webapp/css/embedded.less b/wise-editor/src/main/webapp/css/embedded.less index aaf6abbf..eb71c597 100644 --- a/wise-editor/src/main/webapp/css/embedded.less +++ b/wise-editor/src/main/webapp/css/embedded.less @@ -2,15 +2,16 @@ /* Overwrite some styles */ -div#headerInfo{ - height:0; -} -div#header { - height:35px; +div#headerInfo { + height: 0; } -div#headerMapTitle,#headerActions,#headerLogo { - display:none; +div#header { + height: 35px; +} + +div#headerMapTitle, #headerActions, #headerLogo { + display: none; } /* Footer Styles */ 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 ebf33a27..cad3f7ef 100644 --- a/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java +++ b/wise-webapp/src/main/java/com/wisemapping/filter/UserLocaleInterceptor.java @@ -43,16 +43,9 @@ public class UserLocaleInterceptor extends HandlerInterceptorAdapter { if (user != null && session != null) { String userLocale = user.getLocale(); - final String sessionLocale = (String) session.getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME); - if (userLocale != null && !userLocale.equals(sessionLocale)) { -// LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); -// if (localeResolver == null) { -// throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?"); -// } -// LocaleEditor localeEditor = new LocaleEditor(); -// localeEditor.setAsText(userLocale); -// localeResolver.setLocale(request, response, (Locale) localeEditor.getValue()); - session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, userLocale); + final Locale sessionLocale = (Locale) session.getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME); + if ((userLocale != null) && ((sessionLocale == null) || (!userLocale.equals(sessionLocale.getISO3Language())))) { + session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, new Locale(userLocale)); } } return true; diff --git a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties index 397b5437..f06e8880 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties +++ b/wise-webapp/src/main/webapp/WEB-INF/classes/messages_es.properties @@ -261,3 +261,4 @@ LAST_UPDATE=Ultima Actualización LAST_UPDATE_BY=Ultima Actualización Por SIZE=Tamaño NO_PRODUCTION_DATABASE_CONFIGURED=COMPLETE +CHANGE_LANGUAGE=Cambiar Idioma diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml index dfa371cc..f40ac797 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-servlet.xml @@ -70,9 +70,7 @@ - - + class="org.springframework.web.servlet.i18n.SessionLocaleResolver"/> diff --git a/wise-webapp/src/main/webapp/jsp/errorTemplate.jsp b/wise-webapp/src/main/webapp/jsp/errorTemplate.jsp index 230cedf7..7c7b57e1 100644 --- a/wise-webapp/src/main/webapp/jsp/errorTemplate.jsp +++ b/wise-webapp/src/main/webapp/jsp/errorTemplate.jsp @@ -1,6 +1,8 @@ <%@ page import="org.apache.log4j.Logger" %> +<%@ page import="com.wisemapping.security.Utils" %> +<%@ page import="com.wisemapping.model.User" %> <%@ page autoFlush="true" buffer="none" %> <%@ include file="/jsp/init.jsp" %> @@ -20,6 +22,7 @@ if (exception != null) { exception.printStackTrace(response.getWriter()); String usrMail = "anonymous"; + final User user = Utils.getUser(false); if(user!=null) { usrMail = user.getEmail();