Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts Users »

fmt:message, fmt:setLocale and struts

Adam Hardy

2003-11-11

Replies:

Struts and JSTL seem to have different algorithms to establish the
locale to use.

I have JSPs which use <fmt:message> for titles, labels, comments etc and
I have also just started to program a page which will include an
underlying language page to incorporate big paragraphs of localized text.

I thought I would use the struts locale setting in my session for this,
but then I found that with my current browser settings, struts has
chosen EN but JSTL has chosen DE.

I have EN as my first locale preference in my browser, followed by DE,
being in Germany.

In my app I have a default ApplicationResources.properties and just now
to create a test, I copied it to ApplicationResources_de.properties.

Bug or feature, logically expected or are Struts and JSTL purposefully
diverging?


Adam

PS if I rename ApplicationResources to ApplicationResources_en then JSTL
and Struts agree again, on EN.

PPS I can work-around with this:
<c:set var="localeKey">
 <%=org.apache.struts.Globals.LOCALE_KEY %>
</c:set>
<fmt:setLocale value="${sessionScope[localeKey]}"/>

to make JSTL follow Struts.

--
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@(protected)
For additional commands, e-mail: struts-user-help@(protected)



©2008 junlu.com - Jax Systems, LLC, U.S.A.