Tool for accessing ResourceBundles and formatting messages therein.
Template example(s):
$text.foo -> bar
$text.hello.world -> Hello World!
#set( $otherText = $text.bundle('otherBundle') )
$otherText.foo -> woogie
$otherText.bar -> The args are {0} and {1}.
$otherText.bar.insert(4) -> The args are 4 and {1}.
$otherText.bar.insert(4,true) -> The args are 4 and true.
Toolbox configuration example:
<tool>
<key>text</key>
<class>org.apache.velocity.tools.generic.ResourceTool</class>
<parameter name="bundles" value="resources,com.foo.moreResources"/>
<parameter name="locale" value="en_US"/>
</tool>
This comes in very handy when internationalizing templates.
Note that the default resource bundle baseName is "resources", and
the default locale is the system locale. These may both be overridden
in your toolbox config as demonstrated above.
Also, be aware that very few performance considerations have been made
in this initial version. It should do fine, but if you have performance
issues, please report them to dev@velocity.apache.org, so we can make
improvements.
author: Nathan Bubna version: $Revision: 498714 $ $Date: 2006-11-27 10:49:37 -0800 (Mon, 27 Nov 2006) $ since: VelocityTools 1.3 |