translateToken

From AgileApps Support Wiki
Revision as of 23:13, 20 December 2010 by imported>Aeric (Text replace - 'translateToken(' to 'Functions.translateToken(')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The translateToken API accesses a Custom Label (a message) defined in the Translation Workbench.

Syntax
String result = Functions.translateToken(String key) 
String result = Functions.translateToken(String key, String [] args)
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}."
String [] args = {"nice", "walk"};
String msg = Functions.translateToken("#custom.go_msg", args));
    // ==> "It's a nice day for a walk."