You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andrew Stepanenko <an...@gmail.com> on 2006/12/15 13:10:23 UTC

[s2] switching locale without an action

Hello,

is it possible to switch locale for <s:property
value="%{getText('key')}"> tag on a stand alone JSP, that is a JSP
which is not the result of an Action?

Having read about i18n-interceptor
(http://cwiki.apache.org/WW/i18n-interceptor.html) and Migrating to
Struts 2 tutorial
(http://opensource.atlassian.com/confluence/oss/display/STRUTS/Migrating%20Tutorial)
I was able to get locale switched for an action:

<s:url id="en" action="Welcome">
   <s:param name="request_locale">en</s:param>
</s:url>
<s:url id="uk" action="Welcome">
    <s:param name="request_locale">uk</s:param>
</s:url>

<a href="<s:property value="en" />">Eng</a>
                                                                <a
href="<s:property value="uk" />">Ukrainian</a>

So, when I click on the above links, Welcome.action is executed with
new locale and all <s:property> tags which retrieve i18n strings on
the result page return the appropriate localized content.

But what to do when I have just a JSP page with <s:property> tags
without an action? If I build the url without an action attribute:
<s:url id="uk">
    <s:param name="request_locale">uk</s:param>
</s:url>

and click on that link, <s:property> tags are not updated. Also, I'm
able to change the locale on action-less JSP by setting struts.locale
property in struts.properties, but I need to change it during run
time. Or am I forced to have links to actions only in my webapp, to be
able to change locale dynamically for all pages?

I remember, In Struts1, after you've executed LocaleAction, all
<bean:message> tags returned the appropriate content for selected
locale even on simple JSPs.

Thank you,
Andrew Stepanenko

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