Dynamic translation for record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
we are adding options through catalog client scripts how can we translate the option text in other language
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @AnjaliAnjal ,
Please check references below might help you.
Thanks,
Pradeep
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Refer below,
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0963935
If this helped to answer your query, please mark it as helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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..
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/