UI Messages translation on client script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 03:42 AM
Hi all,
I see that is possible handle U Message translation also in client scripts.
If on server side I use the command
gs.getMessage('MY KEY');
I can use the ${} notation both on HTML and client script
HTML
<h1>${'MY KEY'}</h1>
Client Script
var message = ${'MY KEY'};
But my question is, how right handle on client side the messages key that contains parameters?
On server side I can use this notation:
gs.getMessage('Hi {0}, {1}', ['Mark', 'Good afternoon'] );
There is something similar on client side?
Which is the best approach for this kind of sentences on client side?
I need to handle them inside a service portal widget.
Thanks
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 04:00 AM
Hi Michele,
You may find this previous thread helpful:
Hope this helps,
Shane

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 12:16 AM
Hi Shane, thank you for your suggestions, but under Service Portal client script seems that getMessage() method doesn't work anyway.
For that reason I saw that on client script we can use the ${} API to get message content.
But I didn't find if there are a way to make also the parameters substitution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2022 04:17 AM
Hey,
One thing that I want to point, on client side, it works as :
getMessage("YOUR_MESSAGE_KEY", function(msgString) {
g_form.showFieldMsg('field_name', msgString, 'error');
});
getMessage(String) on client side uses only one parameter unlike server side.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 12:18 AM
Hi
For that reason I saw that on client script we can use the ${} API to get message content.
But I didn't find if there are a way to make also the parameters substitution.