Beispiel #1
0
 public function detect()
 {
     $langs = $this->options();
     if (isset($_COOKIE['wLang']) && isset($langs[$_COOKIE['wLang']])) {
         return $_COOKIE['wLang'];
     }
     $lang = '';
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $negotiation = new ptlis\ConNeg\Negotiation();
         $lang = $negotiation->languageBest($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'application/json;q=1,application/xml;q=0.7,text/html;q=0.3');
     }
     if (!$lang) {
         return $this->default;
     }
     $l10 = new l10n();
     $map = $l10->catalog($lang);
     if ($map && isset($map['localeFallback'])) {
         return $map['localeFallback'];
     }
     return $this->default;
 }