velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@alaska.net>
Subject Re: Context availability during method invocation / ReferenceInsertionEventHandler
Date Thu, 06 Jan 2005 17:20:41 GMT
Vincent van Beveren <vincent@nazarene.nl> wrote:
> I would like to simplify the 
> following piece Velocity code:
> 
> $locale = ... user defined locale ...      // this is done while setting 
> up the context
> 
> Description: $product.description.toString($locale)
> Title: $product.title.toString($locale)
> 
> In which the class product has a method 'getDescription' which returens 
> a home-made object of the class LocaleData. LocaleData is basically a 
> map with as key a locale and as value an object, usually a string. 
> Somewhat like a ResourceBundle (but not quite)
> 
> The simplified version would be like this.
> 
> $locale = ... user defined locale ...// this is done while setting up 
> the context
> 
> Description: $product.description
> Title: $product.title
> 
> Anyone has any idea how to accompish automatic parsing of localized data?

What about setting up a localizer velocity tool helper class that handles 
this for you?

] $localizer = ... helper tool with user defined locale ...// this is done 
while setting up the context
] 
] Description: $localizer.get($product.description)
] Title: $localizer.get($product.title)

Or if you wanted to get the localization completely out of the template, use

] Description: $product.localeDescription
] Title: $product.localeTitle

and have those two methods directly call the localizer helper class.


Note that this is actually a question about the use of velocity and not the 
development of velocity, so I've changed the destination mailing list from 
velocity-dev@jakarta.apache.org to velocity-user@jakarta.apache.org

-Mike

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


Mime
View raw message