You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Stephan R. Mueller" <st...@stud.leuphana.de> on 2010/01/28 22:30:03 UTC

Re: I18nInterceptor / request_locale not working as expected [INVALID/SOLVED]

I beg your pardon for spamming.

I'm mixing JSTL/Struts2 and my i18n messages
are generated using JSTL.
JSTL uses a java.util.Locale Object stored in the session
via key "javax.servlet.jsp.jstl.fmt.locale".
While Struts2 uses it's own key.

Now using the JSTL key to stuff the current locale into
and everything is fine.

So long,
Stephan


Am 28.01.2010 um 20:07 schrieb Stephan R. Mueller:

> Hi list,
> 
> I'm using struts 2.1.8 with JDK6
> 
> I've Message.properties | Message_de_DE.properties
> and Message_en_US.properties.
> 
> When switching the local via a browser plugin everything
> works fine and I can see that Session.WW_TRANS_I18N_LOCALE
> contains the expected locale (de_DE or en_US).
> Now I've added a languages.jsp that contains 2 links
> Constructed like this:
> <s:url id="url" action="./languages">
>            <s:param name="request_locale">en_US</s:param>
>        </s:url>
>        <s:a href="%{url}">English</s:a>
>    </li>
>    <li>
>        <s:url id="url" action="./languages">
>            <s:param name="request_locale">de_DE</s:param>
>        </s:url>
>        <s:a href="%{url}">Deutsch</s:a>
> 
> When using one of these links I can see that 
> Session.WW_TRANS_I18N_LOCALE changes it's value
> accordingly but the displayed language stays the same and
> doesn't change.
> languages.jsp uses an action like the following:
> --snip-
> public class LanguagesShowAction extends ActionSupport implements ServletRequestAware {
> 
> 	HttpServletRequest request;
> 	private Map<String, Object> application;
> 	private Map<String, Object> session;
> 	
> 	public String execute() {
> 		
> 		application = ActionContext.getContext().getApplication();
> 		session = ActionContext.getContext().getSession();
> 		session.put("referer", "languages");
> 		
> 		String localeParam = request.getParameter("request_locale");
> 		
> 		System.out.println("localeParam = " + localeParam);
> 
> 		if (localeParam != null && !localeParam.isEmpty()) {
> 			return "localeChngd"; //used to redirect to another jsp
> 		}
> 		System.out.println("loading languages page");
> 		return SUCCESS; 
> ---snap---
> 
> Any ideas on what I may have done wrong?
> Additional info needed?
> 
> Regards,
> Stephan
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org