struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>
Subject Re: content-language header with Struts2 does not uses the invocation locale
Date Wed, 10 Oct 2012 16:53:08 GMT
Created!! https://issues.apache.org/jira/browse/WW-3886

I hope the explanation is clear.

Thanks

JL

2012/10/10 Lukasz Lenart <lukaszlenart@apache.org>

> 2012/10/10 JOSE L MARTINEZ-AVIAL <jlmagc@gmail.com>:
> > Hi all,
> >  I'm using Struts 2.2.3. I've setup a property "struts.locale" with value
> > "es_ES", for Spanish. But my application is multilanguage, so I setup the
> > locale in the request using an interceptor:
> >
> > public String intercept(ActionInvocation invocation) throws Exception {
> > [...]
> > <get locale for the user>
> > [...]
> > invocation.getInvocationContext().setLocale(userLocale);
> > return invocation.invoke();
> > }
> >
> >
> > The action and the JSPs(I'm using Tiles),correctly use the locale I
> set(so
> > the response has the body in the correct language), but the header
> > content-language is returning always "es_ES", no matter the locale I put
> in
> > the invocationcontext.
> >
> > Any ideas on how can I get the correct locale in the header? a Meta tag
> in
> > the page is not an option, since I have the same problem even with
> > JSONResults.
>
> Try to set struts.locale to empty string
>
> struts.locale=
>
> or something that cannot be parsed as a Locale
>
> struts.locale=es_es_es
>
> then Dispatcher will use Locale from HttpServletRequest, but anyway
> please report a bug, Dispatcher should base on LocaleProvider, right
> now it looks like this:
>
>         Locale locale = null;
>         if (defaultLocale != null) { // <-- struts.locale
>             locale = LocalizedTextUtil.localeFromString(defaultLocale,
> request.getLocale());
>         }
>         if (locale != null) {
>             response.setLocale(locale);
>         }
>
> and the ActionContext is initialized as:
>
>         Locale locale;
>         if (defaultLocale != null) {
>             locale = LocalizedTextUtil.localeFromString(defaultLocale,
> request.getLocale());
>         } else {
>             locale = request.getLocale();
>         }
>
> anyway there is a mismatch :P
>
>
> Thanks in advance
> --
> Ɓukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message