Ejemplo n.º 1
0
 /**
  * Setup internationalization using gettext
  *
  * Uses the preferred user language or the browser suggested language or our default.
  *
  * @return  string                      Detected locale code
  *
  * @see     Translator::DEFAULT_LOCALE  For the the default locale code.
  */
 protected function detectLocale()
 {
     $auth = Auth::getInstance();
     if ($auth->isAuthenticated() && ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) !== null) {
         return $locale;
     }
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         return Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
     }
     return Translator::DEFAULT_LOCALE;
 }
Ejemplo n.º 2
0
 /**
  * Return the preferred locale based on the given HTTP header and the available translations
  *
  * @return string
  */
 protected function getLocale()
 {
     $locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
     return $locale;
 }