You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mike Kienenberger <mk...@alaska.net> on 2005/01/06 18:20:41 UTC

Re: Context availability during method invocation / ReferenceInsertionEventHandler

Vincent van Beveren <vi...@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