The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Set the language by parameter in Service Portal

guiguille
Giga Expert

Hey guys,

I wanted to know if it was possible to set the language of a service portal page in the link. I have a public portal, I'll be sending the link to access the ticket view by mail to users not registered in ServiceNow. I need to support 4 different languages (information that I previously have), and I would like to send in the link itself something that will make ServiceNow recognize the language. The other option is to have 4 pages, in that case what I need to know if it's possible to set the language of a particular page by default.

Any thoughts?

Thanks!

1 ACCEPTED SOLUTION

Should basically put the language in a parameter in the url,


Then on the page have a widget with something like this in the server script:


var lang = $sp.getParameter('lang');//the URL parameter


var util = new I18nUtils();



util.setLanguage(lang);



but remember this will set the language for the whole session


View solution in original post

9 REPLIES 9

larstange
Mega Sage

Hi



In this thread its shown how to let unauthenticated users change their language Choose a language in Service Portal without logging in



Basically its a matter of running the following server side code



var user = gs.getUser();


user.setPreference("user.language", input.value);


user.savePreferences();



You could add a visually invisible widget to your portal page which looks for a language parameter in the URL and if one is there is updates the language and reloads the page.



Alternatively create a public UI page, which sets the language before redirecting to the service portal. You won't be able to set the language on the first load.


Should basically put the language in a parameter in the url,


Then on the page have a widget with something like this in the server script:


var lang = $sp.getParameter('lang');//the URL parameter


var util = new I18nUtils();



util.setLanguage(lang);



but remember this will set the language for the whole session


Hi Göran,

I was wondering if using your approach you were able to set the correct language on first page load?

I am working on a requirement to display a public Portal page in different languages depending on some background logic. I have the above function firing off at the very beginning of a widget's server script, the problem is that the page is still loaded in the default system language at first. Only after page reload, the correct language is displayed. It looks like what Lars has mentioned that it is not possible to do that, I hope to find a solution that will be the least annoying for the users.

Having to reload the page immediately after first load is not something that would ever fly I am afraid. Any better ideas? I was also thinking about some "loading" animation but it still makes for less seamless user experience.

Thanks!

Hi,

Sorry for the late reply. hmm.. if the user is going straight for the portal it's hard to check the language before the portal has started to load. I think you are thinking of the same thing I am. Perhaps have a "landing page" with just a small load icon or similar that says something cool and while it does that you set the language and redirects the the correct page. If you make the pages in a nice way, it doesn't look like a reload, which in a User Experience would be nicer.

//Göran