Difference between revisions of "TranslateToken"
From AgileApps Support Wiki
imported>Aeric m (Text replace - 'translateToken(' to 'Functions.translateToken(') |
imported>Aeric |
||
Line 15: | Line 15: | ||
:A string containing the selected message in the user's currently active language, with specified arguments substituted. | :A string containing the selected message in the user's currently active language, with specified arguments substituted. | ||
;Example:In this example, | ;Example:In this example, <tt>go_msg</tt> is a Custom Label in the Translation Workbench created in the "custom" category, where the translation in the user's current language is <tt>"It's a {1} day for a {2}."</tt> Supplying the arguments then allows for variations on the message. | ||
:<syntaxhighlight lang="java" enclose="div"> | :<syntaxhighlight lang="java" enclose="div"> | ||
String [] args = {"nice", "walk"}; | String [] args = {"nice", "walk"}; |
Latest revision as of 19:17, 12 July 2011
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."