Exemplo n.º 1
0
 /**
  * Sets a fixed locale which will be used independently from the user or environments settings
  *
  * @param  string|\Zend\Locale\Locale $locale  Locale to set
  * @throws \Zend\Locale\Exception\InvalidArgumentException When a autolocale was given
  * @throws \Zend\Locale\Exception\InvalidArgumentException When a unknown locale was given
  * @return void
  */
 public static function setFixed($locale)
 {
     if ($locale === 'auto' or $locale === 'root' or $locale === 'fallback' or $locale === 'fixed' or $locale === 'environment' or $locale === 'browser') {
         throw new Exception\InvalidArgumentException('Only fully qualified locales can be used as fallback!');
     }
     $locale = self::_prepareLocale($locale);
     if (isset(self::$_localeData[(string) $locale]) === true) {
         self::$_fixed = array((string) $locale => 1);
     } else {
         $elocale = explode('_', (string) $locale);
         if (isset(self::$_localeData[$elocale[0]]) === true) {
             self::$_fixed = array($elocale[0] => 1);
         } else {
             throw new Exception\InvalidArgumentException("Unknown locale '" . (string) $locale . "' can not be set as fixed!");
         }
     }
     self::$_auto = self::getFixed();
 }