Helpers.translate function Ui Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 04:14 AM
Hi All,
Can some one help me how to do translation in UI builder.
I want to populate value from the databroker.
how to use helpers.translate function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 04:29 AM - edited 02-13-2023 04:40 AM
Hi @Tejaswi25 ,
I was able to find this document on helpers.translate. Hoping that this might help you.
This is used to translate the message based on the user session.
if you are trying to get the Value from Data Broker then you can use the below script and use that in the translate.
var dataBroker = api.data.<data_broker_name>.
Then passing this value to the Translate
helpers.translate(dataBroker);
I think this would work. Please check
helpers.translate(String message, String tokens)
You can use this method with the api - setState(String stateParam, Any value) to bind the translated value to other fields on the page.
message | String | Message to translate. |
tokens | String | Optional. Comma-separated list of parameters to use for replacing string variables. For example:
helpers.translate('Text {0} {1}', 'to', 'translate'); |
String | Translated text string. |
Example
function handler ({api, helpers}) { helpers.translate(‘Welcome {0} {1}!’, user.firstName, user.lastName) .then((translatedText) => { api.setState('greeting', translatedText); }); }
Example
async function handler ({api, helpers}) { const translatedText = await helpers.translate('Welcome to {0}', 'ServiceNow'); api.setState('greeting', translatedText); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 04:32 AM
Can you tell me how to use Translate method in data binding.