diff --git a/htdocs/index.php b/htdocs/index.php index c2a48f4..61b9363 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -18,12 +18,11 @@ #============================================================================== # Language #============================================================================== -require_once("../lib/detectbrowserlanguage.php"); # Available languages $files = glob("../lang/*.php"); $languages = str_replace(".inc.php", "", $files); $languages = str_replace("../lang/", "", $languages); -$lang = detectLanguage($lang, $allowed_lang ? array_intersect($languages, $allowed_lang) : $languages); +$lang = \Ltb\Language::detect_language($lang, $allowed_lang ? array_intersect($languages,$allowed_lang) : $languages); require_once("../lang/$lang.inc.php"); if (file_exists("../conf/$lang.inc.php")) { require_once("../conf/$lang.inc.php"); diff --git a/lib/detectbrowserlanguage.php b/lib/detectbrowserlanguage.php deleted file mode 100644 index 902a56a..0000000 --- a/lib/detectbrowserlanguage.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @license http://www.php.net/license/3_01.txt PHP license - */ - -/** - * split request header Accept-Language to determine the UserAgent's - * prefered language - * - * @param string $defaultLanguage preselected default language - * @return string returns the default language or a match from $availableLanguages - */ -function detectLanguage($defaultLanguage, $availableLanguages) -{ - $acceptedLanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ? htmlspecialchars($_SERVER['HTTP_ACCEPT_LANGUAGE']) : ""; - $languageList = explode(',', $acceptedLanguages); - $choosenLanguage = $defaultLanguage; - foreach($languageList as $currentLanguage) { - $currentLanguage = explode(';', $currentLanguage); - if (preg_match('/(..)-?.*/', $currentLanguage[0], $reg)) { - foreach($reg as $checkLang) { - if ($match = preg_grep('/'.$checkLang.'/i', $availableLanguages)) { - $choosenLanguage= $match[key($match)]; - break 2; - } - } - } - } - return $choosenLanguage; -} - - /** - * vim: sts=4 ts=4 sw=4 cindent fdm=marker expandtab nu - */