diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 2cecbd606ca..3a71a1939b2 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -133,9 +133,6 @@ function dol_loginfunction($langs,$conf,$mysoc) // Instantiate hooks of thirdparty module only if not already define $hookmanager->initHooks(array('mainloginpage')); - $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); - $langs->setDefaultLang($langcode); - $langs->load("main"); $langs->load("other"); $langs->load("help"); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8da9b1fd796..bc9cd14a938 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -388,13 +388,13 @@ if (! defined('NOLOGIN')) if ($dolibarr_main_authentication == 'forceuser' && ! empty($dolibarr_auto_user)) $goontestloop=true; if (GETPOST("username","alpha",2) || ! empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode','alpha',1)) $goontestloop=true; - $langcode=(GETPOST('lang')?((is_object($langs)&&$langs->defaultlang)?$langs->defaultlang:'auto'):GETPOST('lang')); - if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined, however we need lang for error messages. + if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages. { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs=new Translate("",$conf); + $langcode=(GETPOST('lang')?GETPOST('lang','alpha',1):(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); } - $langs->setDefaultLang($langcode); if ($test && $goontestloop) { @@ -677,10 +677,10 @@ if (! defined('NOREQUIRETRAN')) } } } - else // If language was forced on URL +/* else // If language was forced on URL { $langs->setDefaultLang(GETPOST('lang','alpha',1)); - } + }*/ } // Case forcing style from url diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index b62ee1c9371..f24dcca7a67 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -201,10 +201,11 @@ if (! defined('NOREQUIREDB') && ! defined('NOREQUIRESOC')) } -// Set default language (must be after the setValues of $conf) +// Set default language (must be after the setValues setting global $conf->global->MAIN_LANG_DEFAULT. Page main.inc.php will overwrite langs->defaultlang with user value later) if (! defined('NOREQUIRETRAN')) { - $langs->setDefaultLang((! empty($conf->global->MAIN_LANG_DEFAULT)?$conf->global->MAIN_LANG_DEFAULT:'')); + $langcode=(GETPOST('lang')?GETPOST('lang','alpha',1):(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); }