Optaining user language in a catalog script with g_user?

jesusemelendezm
Mega Guru

Hi, I need to display a msg if user language is "English". I am working with Var loginLanguage = g_user.getClientData("loginlanguage"); but the language value is undefined? my current language is English. Any help is appreciated.

1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

There's a global variable called "g_lang" that you can use.   The value would be "en" for English.



e.g. alert(g_lang) will display "en" in an alert dialog.


View solution in original post

20 REPLIES 20

if(CostValue == 'BADVALUE'){


          alert(getMessage("u_catalog_please_enter_a_number"));


}




Sadly it looks like getMessage() wont work on the client side


Cheers,


- James


Weird, it actually works the second time around:


find_real_file.png



So if you want it to run 100% of the time and be performance friendly, you could create a new String variable for the item (or Variable Set if need on more items) with a default value of "javascript:gs.getUser().getLanguage();".   Create a UI Policy to hide it so it is not visible to the user.   Then you have the user's language:



find_real_file.png


Thanks, that is a far better solution that what I was doing with AJAX.


I will go with that.



Thanks!


- James


It's not ideal using a variable just for that, but sometimes we just have to use what we can  


Yep,.. the amount of workarounds I have had to set up for this implementation so far is just mindblowing. Hopefully Geneva will be better.