The Zurich release has arrived! Interested in new features and functionalities? Click here for more

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

Pradeep Thipani
Mega Sage

Hi @AnjaliAnjal ,

 

Please check references below might help you.

 

https://www.servicenow.com/docs/bundle/yokohama-platform-administration/page/administer/dynamic-tran...

 

https://www.servicenow.com/community/employee-center-forum/how-to-dynamically-translate-portal-conte...

 

Thanks,

Pradeep

 

 

 

 

"If this response was useful, please select 'Accept as Solution' and mark it as 'Helpful.' This helps me provide better answers and assists the community ".

Regards,
Pradeep

kaushal_snow
Mega 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..

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/