Set language for SSO users


#1

Hi,

I have been trying to automatically set language for my SSO users using the Accept-Language headers. As far as I can see this should be supported by Discourse.

I enable the two options below:

image

Then with Chrome, I use an extension to set the Accept-Language:
image

Unfortunately, my UI stays in English. I tried different formats for accept-language (fr, Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5…) with no luck…

Any idea?

Thx,
Seb


(Simon Cossar) #2

The set locale from header setting will not work with SSO. It only sets the locale for anonymous (not logged in) users. When SSO isn’t enabled, it will also set the locale for a user when they first register based on their language header. When SSO is enabled, users are created through a different process and the accept language header has no affect on their locale.


#3

Thx for your answer. Is there any work around?

For instance, would it possible to use a parameter (locale) to automatically set the language?


(Simon Cossar) #4

The only workaround I can think of would be to create a plugin that added locale to the Discourse SSO parameters.


(Jeanmonod David) #5

I have the exact same issue. My user interface is define at first by the browser language of my user, but once connected it fallback to the default discourse language. I just look at the code, and I’m now sure we can solve this with a plugin. Maybe we could implement this in the core. Seems some line of code into

would do the trick. Can you be interested in a PR for this? The PR would be “Allow to set user locale through SSO”


Switch language via URL?