When I login to the site, i always keep getting the English language.

Re: When I login to the site, i always keep getting the English language.

by Salman Zaidi -
Number of replies: 0

Hi David,

Thanks for reply.

I have unchecked lang auto detection as I dont wanna use browser language.

I assume (and this is requirement) that if user selects language from login page,  the next page should be appeared in that language regardless of user preferred language or browser language.

I am not giving any access to users or student to set their own parameters. Usually, any student or user who wants to use his / her preferred language should be able to see 'selected language' in next page after selecting the same in login page.

I attempted some code hacks to get current language, but that changes to en after login page submit to next page. Another hook I tried to get the URL string by $PAGE->url and substr($PAGE->url,-2) to get the lang code, but it changes to en as well after next page appears.

But, I have successfully done it in reverse, like if user logout, he/she would see the same language on login page which was selected in after-login page. I achieved this by adding the code in logout.php

In logout.php file at ling 41, I added this code.

$currlang = current_language();
if ($login)
{ $redirect = get_login_url(); }
else
{ $redirect = $CFG->wwwroot.'/'; }
$redirect .= (isset($_POST['lang']) ? '?lang='.$_POST['lang'] : '');
$redirect .= "login/index.php?lang=".$currlang;


---------------------------------------------

Any help in this regard?  Thanks.