function get_browser_language() { if (isset($_COOKIE['language'])) { if ($this->exists($_COOKIE['language'])) { $this->set($_COOKIE['language']); return true; } } $browser_languages = array('deu' => 'de([-_][[:alpha:]]{2})?|german', 'eng' => 'en([-_][[:alpha:]]{2})?|english', 'spa' => 'es([-_][[:alpha:]]{2})?|spanish', 'fra' => 'fr([-_][[:alpha:]]{2})?|french', 'ita' => 'it|italian', 'nld' => 'nl([-_][[:alpha:]]{2})?|dutch', 'pol' => 'pl|polish', 'rus' => 'ru|russian'); $httpAcceptLanguage = MyOOS_Utilities::getServerVar('HTTP_ACCEPT_LANGUAGE'); if (!empty($httpAcceptLanguage)) { foreach (explode(',', $httpAcceptLanguage) as $code) { foreach ($browser_languages as $key => $value) { if (preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/', $code) && $this->exists($key)) { $this->set($key); return true; } } } } $this->set(DEFAULT_LANGUAGE); }