cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the user language ?

riogrande
Champ in-the-making
Champ in-the-making
Hi,

I would like to know if there is a way to get the language with JavaScript ?
Because the "Interface Language" is not directly linked to the user profile so there is not way to do something like person.language Smiley Tongue

My idea is to send an email depending on the user language preference (by using a different template).

thanks.
6 REPLIES 6

scouil
Star Contributor
Star Contributor
Hi,

Same question for the same purpose two years later.
Anyone got a solution since?

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

This is working in a webscript :
var acceptLanguage = headers["accept-language"];

Just note that it's not working in a workflow : https://forums.alfresco.com/en/viewtopic.php?f=53&t=42238&p=123546#p123497

scouil
Star Contributor
Star Contributor
Hello,

Thanks for your answer. The problem is that I can only retrieve the language of the user currently calling the webservice.
In my case I want to trigger an email to someone else based on the preferred language of that other person.

I ended up with a somewhat similar solution. Every time a user connect to my webservice I retrieve headers["accept-language"] and store it in  person.properties["preferenceValues"] .
That property is a json so I can just add my custom property in here.
Then once it's linked to the user node, I can access it whenever I want.

But there must already be a language associated with the user profile since Alfresco explorer interface manage to remember the user preferred language entered in his profile. It just doesn't seen to be exposed via javascript.

dranakan
Champ on-the-rise
Champ on-the-rise
Is it not what you store ?
person.properties["{http://www.alfresco.org/model/system/1.0}locale"]

scouil
Star Contributor
Star Contributor
Damn right!
Was it already there attached to the person in 3.4? I don't understand how I possibly missed it!

Sorry it's not my topic so the point is not mine to give and I can't close the topic but that's exactly what I was searching for.
Thanks

dranakan
Champ on-the-rise
Champ on-the-rise
I don't know about the 3.4… I just try in 4.0b. Your savior is not me… but lukasz_turakiewicz 🙂
Best regards