Dynamic translation for record producer

AnjaliAnjal
Tera Contributor

we are adding options through catalog client scripts how can we translate  the option text in other language

 

4 REPLIES 4

kaushal_snow
Giga Sage

Hi @AnjaliAnjal ,

 

Best Practices for Dynamic Translations in Catalog Scripts

 

1. Use getMessage() with Preloaded UI Messages:

 

The recommended approach is to define translation keys in the Messages (sys_ui_message) table and reference them in your script:

 

getMessage("your.message.key", function(translatedText) {
g_form.addOption('your_variable', translatedText, translatedText);
});

 

Make sure to list "your.message.key" in the Messages field of your Catalog Client Script so it's preloaded for faster, reliable translation retrieval on form load...


2. Use ServiceNow Localization Framework

 

For translating Catalog Items, Record Producers, variables, and their choices, Use the Localization Framework to translate catalog definitions and variables. This ensures static text including option choices display correctly based on user language preferences.

 

3. Alternatively: Translate at Runtime with getMessage()

When dealing with dynamically generated options (e.g., based on user input or logic), using getMessage() on the client is highly effective:

 

 

getMessage("dynamic.option1", function(msg) {
g_form.addOption('variable_name', msg, msg);
});

 

This will fetch the user specific language string before adding the option...

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community..