Translate Content Examples
Last modified by Manuel Leduc on 2026/08/05 17:15
| Shows how to translate content, using the Message Tool |
| Type | Snippet |
| Category | |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
Table of contents
Description
In Groovy
This snippet allows you to use the internationalized messages in Groovy. Parameters can also be passed as is shown in the example below:
def msgTool = xcontext.context.getMessageTool();
def paramList = ["Apples", "pears", "oranges"];
print msgTool.get("fruits", paramList);
print msgTool.get("apples");You also need to add the key/value pairs to a Document Resource Bundle (see Internationalizing Applications for more details).
fruits={0}, {1} and {2}!
apples=An apple a day keeps the doctor away!The result should look like this:
Apples, pears and oranges!
An apple a day keeps the doctor away!In Velocity
key=Hello {0}, you are {1} years old and a {2} {3}
$msg.get('key', ['John', 18, 'dead', 'zombie'])Translate StaticList items
<Space>.<ClassName>_<propertyName>_<listIndex>=your key