Hello everyone,
I'm trying to make Spring Surf work with Alfresco and
set locale as user select in login page.
I actually set locale but messages of xxxx.get_ja.properties are always displayed whatever locale I choose.
So far, I've done for customization as followings.
####### [ADD]
jp.aegif.springframework.extensions.surf.mvc.Local eResolver
this class receives request parameter sent from login.ftl and set locale using I18NUtil#setLocale.
jp.aegif.springframework.extensions.surf.mvc.Login Controller
replaced default LoginController with this class to set locale in it.
####### [CHANGE]
SRC_MAIN_WEBAPP/WEB-INF/templates/sample/loginf.ftl
added select component which includes values "en_US", "de_DE" and "ja_JP".
SRC_MAIN_WEBAPP/WEB-INF/config/web-application-config.xml
override default LoaleResolver bean definition with custom LocaleResolver class.
<bean id="localeResolver"
class="jp.aegif.springframework.extensions.surf.mv c.LocaleResolver" />
override default LoginController bean definition with custom LoginController class.
<bean id="loginController"
class="jp.aegif.springframework.extensions.surf.mv c.LoginController">
<property name="cacheSeconds" value="-1" />
<property name="useExpiresHeader">
<value>true</value>
</property>
<property name="useCacheControlHeader">
<value>true</value>
</property>
</bean>
#######
and comment out default Surf codes because I want to let Surf work using locale selected in login.
org.springframework.extensions.surf.site.servlet.B aseServlet
56 //I18NUtil.setLocale(I18NUtil.parseLocale(language)) ;
org.springframework.extensions.webscripts.servlet. mvc.WebScriptView
119 //I18NUtil.setLocale(I18NUtil.parseLocale(language)) ;
org.springframework.extensions.webscripts.servlet. WebScriptServlet
141 //I18NUtil.setLocale(I18NUtil.parseLocale(language)) ;
#######
I also debugged by changing I18NUtil#getLocale as...
98 public static Locale getLocale()
99 {
100 Locale locale = threadLocale.get();
101 System.err.println("threadLocale: " + threadLocale.toString());
102 if (locale == null)
103 {
104 // Get the default locale
105 locale = Locale.getDefault();
106 System.err.println("[aegif] I18NUtil: locale == null. Get DefaultLocale");
107 } else {
108 System.err.println("[aegif] locale already set -> " + locale);
109 }
110 return locale;
111 }
Outputs are...
[aegif] locale already set -> en_US
threadLocale: java.lang.ThreadLocal@6f1dc409
[aegif] locale already set -> en_US
threadLocale: java.lang.ThreadLocal@6f1dc409
[aegif] I18NUtil: locale == null. Get DefaultLocale (**NOTE: Where has "en_US" setting gone?)
threadLocale: java.lang.ThreadLocal@6f1dc409
[aegif] I18NUtil: locale == null. Get DefaultLocale
Locale seems to be set with "en_US" a bit after login.
But "en_US" disappears suddenly.
Why does it happen? Do I have any mistakes?
Thanks in advance.
---
mryoshio


Reply With Quote
