Can we use gs.getmessage() to enable email translations

AndyLock
Mega Guru

We have an issue where we will have ELEVEN languages for end users (not ITIL users, who will use English), and possibly more languages in the future.

The workable proposals by b-rad and Chuck to create a language version of each end-user email, a matching rule to trigger the email to be sent in each language, then managing the portal translations in different place is one that's repeated everywhere I look. It's a solution that is probably OK with just two or three languages but, for our scenario, eleven or more languages appears un-scalable and inelegant.

I would prefer to leverage gs.getMessage() for end-user emails (where it goes to only the caller) so that both Portal and Email translations are held in just one place. This way translations can easily be managed by native speakers on a spreadsheet, then imported/updated by admins to the sys_ui_message table. No need for admins to go into each email template to change the wording for the 'Take me to the incident' button, or to create new triggers and templates for a new language - we can do it in one place from a single import from work done by others, and simply make sure the new language appears in the language picker.

I realise that gs.getmessage() is designed to work on the system language by default, so my question: is there a way that we can force a certain email to reference the user language instead of the system language?

EDIT - If there is a way to use the sys_iu_message table based on the recipients language, can you please provide details on how.

Note: emails going to multiple recipients would be in English. The decision to use system language or user language should be configurable per email, ideally by a common script that can be added to an event or a template.

thx,

Andy.

5 REPLIES 5

Fabian Kunzke
Kilo Sage
Kilo Sage

Hello Andy,

Yes you can. For a matter of fact, most of the email scripts already use this oob. Check the incident notifications. The notifications scripts use the gs.getMessage() alot.

 

Now about the second part: To set which part of the mail/which mail would be using which language would be needing some added coding. You may have to "manually" query the sys_ui_message table to force a certain language.


Greetings

Fabian

AndyLock
Mega Guru

Hi Fabian,

I have looked at the existing templates and I understand how to use gs.getmessage() to allow emails to query the sys_ui_message table for system language. I realise that added coding is required to send emails in a non-system language. Do you know how to create the code to achieve the outcomes I need?

thx,

Andy

 

Hello,

 

Within the mail scripts (not the templates!) you can use serverside javascript. This means the code could look somewhat like this:

 

var message;

var greeting = new GlideRecord('sys_ui_message');
greeting.addQuery('language','en');
greeting.addQuery('key','greeting');
greeting.query();

if(greeting.next())
{
message = greeting + ' talala';
}

template.print(message);

 

This should work for an example.

Greetings

Fabian

SatheeshKumar
Kilo Sage

Hi andylock,

 

In sys_ui_message table create messages for all languages needed and follow the naming like

key.en   message in english

key.es    mesage in language2

key.zh  message in language3

and in notification scripts use the user's language to pick the required message from message table

 

 

var getuser= new GlideRecord('sys_user');

getuser.get(user_id);

var getLanguage = getuser.preferred_language ;


var key_id = temp_id + "." + getLanguage ;
var gr = new GlideRecord('sys_ui_message');
gr.addQuery('key', key_id);

--> use the result in notifications , so the notification will be triggered based on the user's language