struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paweł Wielgus" <>
Subject Re: S2 - Need advice with Localization
Date Thu, 18 Sep 2008 19:56:09 GMT
Hi Bob,
i would do it like that:

welcomeMessage=Welcome to {0} - Additional information about {1} is available.

then in jsp
<s:property value="welcomeMessage"/>

and in action
public String getWelcomeMessage() {
 return getText("welcomeMessage", varFromDatabase1, varFromDatabase2);

I asume that name and second parameter are constructed somehow
(database or configuration).
I'm not saying that this is most proper, but it will do the job.

Best greetings,
Paweł Wielgus.

2008/9/18 bob fuller <>:
> I am trying to Localize a dynamic message and would like some advice as to how I should
go about it. My main goal is to keep the message itself as 'intact' as possible in my,
doing this will (hopefully) speed up translation by an interpreter. Goals after that are to
use the Struts 2 software correctly and cleanly and also keep the amount of work needed to
a minimum.
> Here's the dynamic message that I want to localize...
> Welcome to SEA (Seattle International Airport) - Additional information about Hotels,
Entertainment, Transportation, and Dining is available.
> The "SEA" & "Seattle International Airport" parts of the message are dynamic. Also,
the following words are dynamic links - "Hotels", "Entertainment", "Transportation", "Dining".
Here is what the message looks like in my file...
> welcomeMessage=Welcome to {0} ({1}) - Additional information about {2}Hotels{3}, {4}Entertainment{5},
{6}Transportation{7}, and {8}Dining{9} is available.
> In my JSP I do this to render the single line of text (I didn't verify that it's syntax
> <s:url var="urlHotel" value="">  <s:param
name="airportCode">    <s:property value="airport.code"/>  </s:param></s:url><s:url
var="urlEntertainment" value="">  <s:param
name="airportCode">    <s:property value="airport.code"/>  </s:param></s:url><s:url
var="urlTransportation" value="">  <s:param
name="airportCode">    <s:property value="airport.code"/>  </s:param></s:url><s:url
var="urlDining" value="">  <s:param name="airportCode">
   <s:property value="airport.code"/>  </s:param></s:url><s:text name="welcomeMessage">
 <s:param value="airport.code"/>  <s:param value=""/>  <s:param>
   <a href="<s:property value="%{urlHotel}"/>">  </s:param>  <s:param
value="'</a>'"/>  <s:param>    <a href="<s:property value="%{urlEntertainment}"/>">
 </s:param>  <s:param value="'</a>'"/>  <s:param>    <a href="<s:property
value="%{urlTransportation}"/>">  </s:param>  <s:param value="'</a>'"/>
 <s:param>    <a href="<s:property value="%{urlDining}"/>">  </s:param>
 <s:param value="'</a>'"/></s:text>
> OK. Thanks for getting this far! I am concerned about the amount of JSP that is needed
for my single dynamic message. Is that just how it is? Or perhaps my approach is flawed? Does
anyone have any advice or perhaps a tutorial suggestion that provides examples 'advanced'
localization examples?
> Thanks.
> _________________________________________________________________
> Get more out of the Web. Learn 10 hidden secrets of Windows Live.
View raw message