- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-09-2020 11:46 PM
The benefit of using translations
You can use Translations in many places. Here are some examples I will use in this Article:
- To set a field message
- Generate an Info or Error message
- Translate options
You can enter the translations in the [sys_ui_message]-table
Plugin for translations
Make sure you have the language you want to translate to installed:
The Callback
To set up a translated Message in the Service Portal you need to use a Callback like so:
getMessage(messageKey, callback)
This is because the getMessage without callback is not supported in the Service Portal:
An example:
Without Callback:
g_form.addErrorMessge(getMessage('Your text in English'))
We get a JavaScript error caused by the system:
With Callback:
getMessage('Your text in English', function (msg) {
g_form.addErrorMessage(msg);
});
We get the error message we want:
The script: Examples
- To set a field message
getMessage('Your text in English', function (msg) {
g_form.showFieldMsg('field_name', msg,'info');
});
- Generate an Info or Error message
info:
getMessage('Your text in English', function (msg) {
g_form.addInfoMessage(msg);
});
error:
getMessage('Your text in English', function (msg) {
g_form.addErrorMessage(msg);
});
- Translate options to add or remove:
To add the option:
getMessage('Your option in English', function(msg){
g_form.addOption('field_name','value', msg);
})
To remove you can just use:
g_form.removeOption('field_name','value');
Thanks
Mark has a great article which mentions you can add the Message field to the Catalog Client script form as well as some other interesting information:
- 4,042 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Dear Willem
Thanks for this article, this is valuable!
One Input: the message-based translation system, where the English term is the "key" and the translation is the "value" can lead to issues which are evident in Service Now.
If, for example, the "key" is "open", it is absolutely unclear if this refers to a verb or an adjective.
When we translate this to another language like German or French or Italian or... many others - this leads to amiguity.
For example "Open" on a Button should read "öffnen", "ouvrir", "aprire" (verb), while "Open Tasks" should read "Offene Aufgaben", "tâches ouvertes" & "assegnazioni aperte". Note how the order also changes in French and Italian, which is yet another problem.
Therefore I would suggest that rather than using English as the "key", the "key" should be artificial. Also, it is not a good idea to split the translations (translating part of an expression), rather the whole expression should be translated.
So I would create a key like "open_verb" and then add an English Translation "open", and also the other translations. This is a bit more work, but it is much more obvious.