Skip to content

Commit

Permalink
Qual: Better init of default lang
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 25, 2013
1 parent b61c576 commit ae322ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 0 additions & 3 deletions htdocs/core/lib/security2.lib.php
Expand Up @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions htdocs/main.inc.php
Expand Up @@ -388,13 +388,13 @@ function analyse_sql_and_script(&$var, $type)
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)
{
Expand Down Expand Up @@ -677,10 +677,10 @@ function analyse_sql_and_script(&$var, $type)
}
}
}
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
Expand Down
5 changes: 3 additions & 2 deletions htdocs/master.inc.php
Expand Up @@ -201,10 +201,11 @@
}


// 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);
}


Expand Down

0 comments on commit ae322ba

Please sign in to comment.