|
Looks up and returns the localized message for the specified key.
String get(String key, String bundle)
|
String get(String key, Object args[])
|
String get(String key, String bundle, Object args[])
|
String get(String key, List args)
|
String get(String key, String bundle, List args)
|
- Parameters
-
- key
-
Message key.
- bundle
-
The (non-default) message-resources bundle that holds the message.
- args
-
Replacement parameters for this message. Typically
an array of Strings or a List of Strings (but any
Object with a reasonable
toString()
method can be used).
- Returns
-
The localized message for the specified key. Returns null if no
message exists for the key passed.
- See Also
-
Struts user's guide on
Internationalized Messages.
The user's locale is consulted to determine the language of the
message. The third, fourth, fifth and sixth signatures take a list
of up to five replacement parameters. The third and fourth signatures
are provided for compatibility with existing applications. The fifth and
sixth signatures are more Velocity friendly.
Assuming that the message resource files contain the following messages:
title=Welcome to Velocity for Struts
test=This message has five replacement parameters: {0}, {1}, {2}, {3}, {4}
label.one=foobar
label.two=woogie!
|
|
then the following Velocity script:
$text.title
$text.get('test', ['bear', 'wolf', 'tiger'])
$text.label.one
$text.label.two
|
|
produces this output:
Welcome to Velocity for Struts
Welcome to Velocity for Struts
This message has five replacement parameters: bear, wolf, tiger, {3}, {4}
foobar
woogie!
|
|
|