struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paweł Wielgus" <poulw...@gmail.com>
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 <bobfuller30004@hotmail.com>:
>
>
> 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 package.properties,
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 package.properties 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
correct)...
>
> <s:url var="urlHotel" value="http://www.somewebsite.com/hotels.do">  <s:param
name="airportCode">    <s:property value="airport.code"/>  </s:param></s:url><s:url
var="urlEntertainment" value="http://www.somewebsite.com/entertainment.do">  <s:param
name="airportCode">    <s:property value="airport.code"/>  </s:param></s:url><s:url
var="urlTransportation" value="http://www.somewebsite.com/transportation.do">  <s:param
name="airportCode">    <s:property value="airport.code"/>  </s:param></s:url><s:url
var="urlDining" value="http://www.somewebsite.com/dining.do">  <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="airport.name"/>  <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.
> http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008
Mime
View raw message