Vincent van Beveren <[EMAIL PROTECTED]> 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 [email protected] to [email protected] -Mike --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
