language : allow to force the language from anoter source than the cookie and the browser params

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2509 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-02-21 19:12:50 +00:00
parent 79bae30807
commit 060f47bce6

View File

@@ -279,7 +279,6 @@ class language
putenv ('LANG='.$languageCode.'.'.$codeset);
putenv ('LANGUAGE='.$languageCode.'.'.$codeset);
$GLOBALS["domframework"]["lang"] = $languageCode;
bind_textdomain_codeset ($package, "utf-8");
bindtextdomain ($package, $repLocale);
textdomain ($package);
@@ -301,14 +300,18 @@ class language
/** The complete stack of language selection
@param string $package The package name (package.(po|mo) files)
@param string $languageCookie The name of the cookie saved in the browser
@param string $forcedLanguage The name of a forced language
@return string The language with format fr_FR to be used */
public function activeLanguage ($package, $languageCookie)
public function activeLanguage ($package, $languageCookie,
$forcedLanguage = null)
{
// Prefered language in the browser
$langNav = $this->languageSelection ("./locale", "fr_FR");
// Language defined in the cookie
$langCookie = $this->languageCookie ($languageCookie);
if ($langCookie !== FALSE)
if ($forcedLanguage !== null)
$languageCode = $forcedLanguage;
elseif ($langCookie !== FALSE)
$languageCode = $langCookie;
else
$languageCode = $langNav;