Custom Login Page Doesn't Pass Language Variable Upon Login.

Custom Login Page Doesn't Pass Language Variable Upon Login.

by Gérald Gallant -
Number of replies: 4

Hi there!

I was wondering if someone could help me figure this out.  My site has the English, French and Spanish language packs.  I've created a custom login page with a combobox to select the language.  However, once logged in, everything reverts to English even though I've passed the lang=fr or lang=es as a url parameter.  How can I get Moodle to serve authenticated content in the language chosen in the login page?

Just thinking out loud...  Once authenticated, does the system look at the user's language preference?  If so, how can I get the login page to update the user's preferred language?

I appreciate any help you can provide.

Gérald Gallant

Average of ratings: -
In reply to Gérald Gallant

Re: Custom Login Page Doesn't Pass Language Variable Upon Login.

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Once authenticated, does the system look at the user's language preference?

Yes it does. And the preferred language set in the profile takes precendence over site's default language and/or autodetected language (requested by the browser).

If so, how can I get the login page to update the user's preferred language?

I'm not sure this is possible. I would expect that the explicit session language (the one specified by ?lang=xx parameter) is set before the user is authenticated and once the user is autheticated, their preferred language overrides the session language.

Please note this is expected behaviour, not a bug. Users just should have their preferred language set correctly in their profile.

In reply to David Mudrák

Re: Custom Login Page Doesn't Pass Language Variable Upon Login.

by Gérald Gallant -

Thanks so much, David!

Unfortunately, we don't know the student's preferred language beforehand, so everyone is set to English by default (our user information comes through LDAP).  It would be great to allow for language consistency right from the login page.  Our users often don't realise that they have to update their language preference, but I guess that's a training issue on our end.

I really appreciate your input.  Have a great day.

Gérald Gallant

 

In reply to Gérald Gallant

Re: Custom Login Page Doesn't Pass Language Variable Upon Login.

by hafsa syeda -

I am having the same problem. Users are able to login in the language preferred. However after login, everything reverts back to english. Please suggest how it can be corrected.

In reply to Gérald Gallant

Re: Custom Login Page Doesn't Pass Language Variable Upon Login.

by Michael Milette -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

See Moodle Language FAQ " I've set a default site language but when I log in it switches to English. Why?" for the solution.

If you don't want it to switch language on you when you logout, see https://tracker.moodle.org/browse/MDL-40699. Unfortunately the solution is not yet part of the Moodle core code.

Best regards,

Michael Milette
www.tngconsulting.ca