Hi Evgeny, your suggestion corrected the behaviour of <fmt:message/> : now it displays the strings in the language set by <fmt:setLocale /> and can be modified on the fly in different parts of the page.
Back to original problem, the <stripes:message /> doesnt care of the locale set by the fmt tag. Ive tried to google the problem and, going to the cache of google for www.stripesframework.org (expired!?) ive found the following link http://209.85.135.132/search?q=cache:PRE_0P2eCOgJ:www.stripesframework.org/display/stripes/Localization+stripes:message+jsp+locale+change with the following sentence: One exception is that <fmt:message> does not call request.getLocale()(1). In the case that a request sends no accept-language headers, you will need to include a call to <fmt:setLocale value="${pageContext.request.locale}"/> before <fmt:message>. that made me think that you were right telling me to put <fmt:setLocale /> in page before the <stripes:message /> but it doesnt seem to work. any suggestion? ty mirko Evgeny Shepelyuk-2 wrote: > > Hello > >> Hi Evgeny and hi everyone reading, >> i've tried all the day to find a workaround but it seems that the >> fmt:setLocale is not a solution. >> I ended my tests with this basic try that demonstrates that, given two >> resources named MyResource_it.properties and MyResource.properties, you >> cant >> switch on the fly the Locale used in a tld. >> >> ---- case 1: >> <fmt:setBundle basename="MyResource" var="res" /><br/> >> <fmt:setLocale value="it" /> >> Italiano: <fmt:message key="sayhello" bundle="${res}"/><br/> >> <fmt:setLocale value="en" /> >> English: <fmt:message key="sayhello" bundle="${res}"/><br/> >> >> ---- result 1: >> Italiano: Ciao! >> English: Ciao! >> >> ---- case 2: (simply switch the order of the setLocale, first en then it) >> <fmt:setBundle basename="MyResource" var="res" /><br/> >> <fmt:setLocale value="en" /> >> English: <fmt:message key="sayhello" bundle="${res}"/><br/> >> <fmt:setLocale value="it" /> >> Italiano: <fmt:message key="sayhello" bundle="${res}"/><br/> >> >> ---- result 2: >> English: Hello! >> Italiano: Hello! >> >> so, back to my problem, the ability to localize a <stripes:message/> in >> different languages in different areas of the page cant be relied upon a >> setLocale, since the setLocale can be set only once before any localized >> output. >> >> if u have any idea to achieve this, it would be welcome. otherwise i'm >> thinkinkg to write my own <mycustomtag:message /> that accept a lang >> parameter >> >> thank u very much >> mirko >> > > Hello, > Well, your code shouldn’t work at all. Because you calling setBundle > _before_ > setting locale, so your bundle variable is created with _current_ locale > and > not the one you're setting in next step. > > First do the following > > Add to web.xml > <context-param> > > <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> > <param-value>StripesResources</param-value> > </context-param> > > This tells servlet container to use StripesResources as default bundle, so > JSTL > will use this file while calling to fmt:message and you shouldn’t pass > bundle > variable to fmt:message. But this is optional if you don't want > StripesResources to be used as default bundle. > > Secondly try the code below anywhere in your JSP > > <fmt:setLocale value="it"/> > <fmt:message key="sayhello"/> > > <fmt:setLocale value="en"/> > <fmt:message key="sayhello"/> > > It works like a charm. Plz note that you have to call setLocale first and > later > call your fmt tags. > > > -- > Regards, > Evgeny Shepelyuk > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Stripes-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/stripes-users > > -- View this message in context: http://old.nabble.com/Problem-with-Internationalization-of-StripesResources-tp26377435p26406488.html Sent from the stripes-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
