Exemplo n.º 1
0
 /**
  * Gets the current language for the user. This is based on the browsers request.
  * No lookups are made.
  * The language must be available in the pool, or set as default, otherwise the default is returned.
  * @return string The language to use.
  */
 public static final function getLanguage()
 {
     $langRequest = self::$defaultLocale;
     $server = new \System\HTTP\Request\Server();
     $browserRequestLang = $server->c_get('HTTP_ACCEPT_LANGUAGE');
     if (!empty($browserRequestLang)) {
         $browserRequestLang = self::callLocaleFunction('acceptFromHttp', $browserRequestLang);
         if (self::isValidLocale($browserRequestLang)) {
             $langRequest = $browserRequestLang;
         }
     }
     $cookie = new \System\HTTP\Storage\Cookie();
     $cookieRequestLang = $cookie->get(self::COOKIE_KEY);
     if (!empty($cookieRequestLang)) {
         if (self::isValidLocale($cookieRequestLang)) {
             $langRequest = $cookieRequestLang;
         }
     }
     return self::callLocaleFunction('getPrimaryLanguage', self::callLocaleFunction('lookup', self::$languagePool, $langRequest, true, self::$defaultLocale));
 }