translateToken
From AgileApps Support Wiki
Revision as of 23:13, 20 December 2010 by imported>Aeric (Text replace - 'translateToken(' to 'Functions.translateToken(')
The translateToken API accesses a Custom Label (a message) defined in the Translation Workbench.
- Syntax
- <syntaxhighlight lang="java" enclose="div">
String result = Functions.translateToken(String key) String result = Functions.translateToken(String key, String [] args) </syntaxhighlight>
- Parameters
-
- key
- The category and token (index key) for the message to retrieve, in the form: "#category.token_name".
- args
- An array of string-arguments to be substituted into the message, in the locations defined by the message format.
- Returns
- A string containing the selected message in the user's currently active language, with specified arguments substituted.
- Example
- In this example, "going_out" is a Custom Label in the Translation Workbench created in the "custom" category, where the translation in the user's current language is "It's a {1} day for a {2}."
- <syntaxhighlight lang="java" enclose="div">
String [] args = {"nice", "walk"}; String msg = Functions.translateToken("#custom.go_msg", args));
// ==> "It's a nice day for a walk."
</syntaxhighlight>