Hi all,
Well I think I figured out what's happening but not why.
I was using <s:debug/> and noticed
session {WW_TRANS_I18N_LOCALE=ga}
locale en_US
With more than one tile in use the locale doesn't get changed
I assume s:text reads off
com.opensymphony.xwork2.ActionContext.locale
and getText takes the default locale and that's why they are different.
I can force the issue in my action
if(session.containsKey("WW_TRANS_I18N_LOCALE")){
Locale.setDefault((Locale)
session.get("WW_TRANS_I18N_LOCALE"));
}
Which will work but isn't the nicest.
I assume this is caused by something in my configuration or someone else would
have come across it by now.
Anyone any idea where I'm going wrong?
Or any idea of a better way to fix the problem?
Thanks
Dave
-----Original Message-----
From: David Kerwick [mailto:[email protected]]
Sent: 09 February 2009 15:57
To: Struts Users Mailing List
Subject: RE: Struts2 + tiles + i18n, getText issue
Hi,
Just discovered this also happens with
<s:textfield key="surname" label="%{getText('surname')}"></s:textfield>
I don't know how to get around that as I can't put s:text in its place.
Am I just doing something wrong? If so what should I be doing?
Any help would be great
Thanks
Dave
-----Original Message-----
From: David Kerwick [mailto:[email protected]]
Sent: 06 February 2009 14:57
To: [email protected]
Subject: Struts2 + tiles + i18n, getText issue
Hi,
I've come across a problem I can't figure out it seems similar to
http://www.mail-archive.com/[email protected]/msg76063.html
These two statements give different results when the language is changed
<s:property value="%{getText('test')}"/>
<s:text name="test"/>
With s:text giving the correct language text but getText always gives the
default language text.
The tiles definition I have is
<definition name="test.basic" template="/WEB-INF/tiles/testTemplate.jsp">
<put-attribute name="body" value="/test.jsp"/>
<put-attribute name="navbar" value="/WEB-INF/pages/navBar.jsp"/>
</definition>
They both work correctly if there's only one tile i.e.
<definition name="test.basic" template="/WEB-INF/tiles/testTemplate.jsp">
<put-attribute name="body" value="/test.jsp"/>
</definition>
So it seems to be something to do with having multiple tiles but since s:text
works the i18n interceptor must be working.
Anyone any idea why getText is ignoring the language?
I came across this when using tabbedPanel and adding i18n to the tab titles.
I'm using Struts struts-2.0.14 and the tiles bundle that comes with it
I change language using the code from HelloWorld.action
<h3>Languages</h3>
<ul>
<li>
<s:url id="url" action="test">
<s:param name="request_locale">en</s:param>
</s:url>
<s:a href="%{url}">English</s:a>
</li>
<li>
<s:url id="url" action="test">
<s:param name="request_locale">ga</s:param>
</s:url>
<s:a href="%{url}">Irish</s:a>
</li>
</ul>
Thanks
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]