AgileApps Support Wiki Pre Release

translateToken

From AgileApps Support Wiki
Revision as of 19:17, 12 July 2011 by imported>Aeric
(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, go_msg 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}." Supplying the arguments then allows for variations on the message.
String [] args = {"nice", "walk"};
String msg = Functions.translateToken("#custom.go_msg", args));
    // ==> "It's a nice day for a walk."