How to change system language in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 02:05 AM
Hi all,
we have several languages in our instance.
During the processing of the workflow, we have some business logic which is sending data to third party system.
Time of sending can be various, it depends on some triggers in the system.
Data must be always in German.
Is it possible to change system language to German in script?
I know that one possible approach is to impersonate as some German speaking user:
gs.getSession().impersonate(current.variables.<USER_VAR>.sys_id);
but this approach is not desired since it creates dependency on certain user and we cannot rely on it.
I have also tried code like:
var session = new GlideSession();
session.setLanguage('de');
but it is not working.
We are currently living with our own translation scripts - which are searching in sys_translated_text table for translations.
I was just wondering if there is another (better) way how to get German translations.
I expect some code which only changes language for current session or for current script and then it switches language back to previous.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 05:01 AM
Hi Peter,
Can you try:
gs.getSession().setLanguage("de");
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 05:06 AM
Hi Sergiu,
unfortunately it's not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2015 06:36 AM
Peter,
What exactly are you looking for to get it in another language?
The values are always in english, it's only the label that changes to a particular language (like 'de' in our case).
See a quick test on my own instance via Background Scripts:
- script run:
var gr = new GlideRecord('incident');
gr.query();
while(gr.next()){
gs.getSession().setLanguage("de");
gs.print('Category: ' + gr.category.getDisplayValue());
}
Result:
[0:00:00.044] Script completed in scope global: script
*** Script: Category: Netzwerk
*** Script: Category: Netzwerk
*** Script: Category: Netzwerk
*** Script: Category: Request
*** Script: Category: Hardware
*** Script: Category: Software
*** Script: Category: Datenbank
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Datenbank
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Software
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Software
*** Script: Category: Hardware
*** Script: Category: Anforderung/Hilfe
*** Script: Category:
*** Script: Category: Software
*** Script: Category: Request
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Hardware
*** Script: Category: Hardware
*** Script: Category: Software
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Request
*** Script: Category: Hardware
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Software
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Request
*** Script: Category: Software
*** Script: Category: Netzwerk
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Hardware
*** Script: Category:
*** Script: Category: Software
*** Script: Category: Anforderung/Hilfe
*** Script: Category:
*** Script: Category: Netzwerk
*** Script: Category: Hardware
*** Script: Category: Software
*** Script: Category: Software
*** Script: Category: Request
*** Script: Category: Software
*** Script: Category: Request
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Hardware
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Netzwerk
*** Script: Category: Anforderung/Hilfe
*** Script: Category: Anforderung/Hilfe
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-12-2016 01:58 AM
Hi Peter
In Fuji I was sucessfully using the following lines to change the session language:
var util = new I18nUtils();
util.setLanguage('de');
But currently I'm also trying to set the session language in Geneva in the login installation exit and it's not working. I tried those two ways:
var util = new I18nUtils();
util.setLanguage('de');
request.getSession().setLanguage("en");
Perhaps the I18nUtils will help in your case.
Best Regards
Christina