struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bOOyah <boo...@nowhere.org>
Subject Re: Translating i18n keys in Struts?
Date Mon, 12 Apr 2004 16:00:56 GMT
Joe Hertz wrote:

> You just need property files defining the various i18n strings.
> 
> http://www.anassina.com/struts/i18n/i18n.html

Sorry Joe - I obviously didn't explain myself adequately.

I already have property files containing i18n keys + strings.  Like this:

     ApplicationResources_en.properties
     ----------------------------------
     menu.item.search="Search"
     menu.item.about="About This Application"
     ...


And in my Struts Action I'm sending a collection of menu entries to the 
JSP (which uses 'html:select' and 'html:optionsCollection' tags to 
render the menu):

     MenuItem item = new MenuItem();

     item.id=1;
     item.value="menu.item.search"
     menuCollection.add(item);

     item.id=2;
     item.value="menu.item.about"
     menuCollection.add(item);
     ...

All this does is render a HTML select list containing the "menu.item..." 
strings rather than the locale-specific strings.

So, in my Action class I have added a helper method that iterates 
through the  menuCollection, replaces the i18n keys with their actual 
locale-specific strings and places THAT collection in the form as the 
menu.  This translation happens every time the Execute() method is called.

But is there some i18n 'magic component' in Struts that would do that 
for me?  Or do I have to rewrite (or reuse) my helper method in every 
Action for now on?

Thanks.
-- 
Sean


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


Mime
View raw message