Logged in user's language

dabraham
Kilo Explorer

How can we check logged in user's language using client script?

6 REPLIES 6

Bhavesh Jain1
Giga Guru

Write a script include and get the current user's lanaguage:



var myUserObject = gs.getUser();


myUserObject.getLanguage(); -- returns the current user's language



Call this script include in client script using GlideAjax and you will have language in client script.


Hi Bhavesh,



Thx for your reply.


But i need to use client script for checking the user language.




Daniel.


richfred
Mega Expert

In addition: When the logged in user language is defined via the user preferences then it's stored in the sys_user table in the language field: preferred_language


Change on this are tracked in the sys_choice table.


The wiki says: The Language field in the User [sys_user] table overrides the default global language for that user's sessions.



The following sequence applies according the wiki:


1. If the language selection at login is enabled, that language is used.


2. If not, the language preference selected using the language picker in the header bar is used.


3. If not, the user's language setting in the User [sys_user] table is used.


4. If none of the above are true, the system default language is used.



So when you only let user define their preferred language in the profile settings then it's possible to refer to this field in the client script. But I assume you want to do this on active session which you just receive a good response on.