IDPv3 internationalization via links and cookies
Simon Lundström
simlu at su.se
Wed Nov 4 08:53:46 EST 2015
On Tue, 2015-11-03 at 13:27:22 -0500, Brent Putman wrote:
> Like other MVC defaults, the LocaleResolver used is one of those
> "special" bean types [2], which gets defaulted in resource
> org.springframework.web.servlet.DispatcherServlet.properties:
>
> org.springframework.web.servlet.LocaleResolver=org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
>
>
> So if we're being conservative, we probably don't want to
> override/replace that (although their cookie one does default to
> falling back to the HTTP Accept-Language header value exposed via
> HttpServletRequest#getLocale()).
I haven't changed that and both Accept-Language and Cookie-based works
(although cookie overrides Accept-Language, of course) so I don't think
you need to change anything.
> Re: changing the locale: I have in the past played around with the
> interceptor Simon mentions [3]. As I recall, it worked OK for me, but
> that was just in plain MVC. I don't know how usage is affected by SWF,
> that probably needs more research.
In my naivety I thought just adding a link to "?lang=en_GB" with
possibly some Javascript which adds the existing query string...
Since I couldn't get the QS "handler" to work I couldn't test it.
If I change the cookie to a new locale and refresh the IDP login page it
works though, so I guess SWF aren't that fragile.
> So that would have to be a 3.2 thing.
I'm adding this to the increasingly larget list of things to do when 3.2
comes out ; )
> Simon, you could probably test this prior to 3.2 by just adding the
> following to the bottom of your system/conf/mvc-beans.xml:
>
> <!-- Import any user defined beans or overrides for the MVC config. -->
> <import resource="../../conf/mvc-beans.xml" />
>
> That's all 3.2 is adding here, I think. That would then allow you to
> have that file exist in user-space conf, and try some of these things
> out. If you get a chance to try, let us know how well it works.
The import works alright, but changing locale via the QS parameter still
doesn't work. This is my conf:
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang"/>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="cookieName" value="lang"/>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor"/>
</list>
</property>
</bean>
As I stated before, if I just change the cookie manually it works.
BR,
- Simon
More information about the users
mailing list