示例#1
0
 /**
  * Retrieve locale object
  *
  * @return Zend_Locale
  */
 public function getLocale()
 {
     if (!$this->_locale) {
         $this->setLocale();
     } elseif ($this->_locale->__toString() != $this->_localeCode) {
         $this->setLocale($this->_localeCode);
     }
     return $this->_locale;
 }
示例#2
0
 /**
  * Retrieve locale object
  *
  * @return Zend_Locale
  */
 public function getLocale()
 {
     if (!$this->_locale) {
         Zend_Locale_Data::setCache(Mage::app()->getCache());
         $this->_locale = new Zend_Locale($this->getLocaleCode());
     } elseif ($this->_locale->__toString() != $this->_localeCode) {
         $this->setLocale($this->_localeCode);
     }
     return $this->_locale;
 }
示例#3
0
 /**
  * test toString
  * expected string
  */
 public function testToString()
 {
     $value = new Zend_Locale('de_DE');
     $this->assertEquals('de_DE', $value->toString());
     $this->assertEquals('de_DE', $value->__toString());
 }
示例#4
0
 /**
  * test toString
  * expected string
  */
 public function testToString()
 {
     $value = new Zend_Locale('de_DE');
     $this->assertEquals($value->toString(), 'de_DE', 'Locale de_DE expected');
     $this->assertEquals($value->__toString(), 'de_DE', 'Value de_DE expected');
 }
示例#5
0
 /**
  * Set current locale in Zend_Locale::setDefault(), Zend_Registry and
  * Adapter.
  *
  * @param Zend_Locale|string $locale
  */
 public static function setLocale($locale = null)
 {
     if (!$locale) {
         $locale = self::findLocale();
     }
     if (is_string($locale)) {
         try {
             $locale = new Zend_Locale($locale);
             if ($locale->__toString() == 'root') {
                 $locale = self::getDefaultLocale();
             }
         } catch (Exception $e) {
             $locale = new Zend_Locale();
         }
     }
     try {
         Zend_Locale::setDefault($locale);
     } catch (Exception $e) {
         Zend_Locale::setDefault(self::getDefaultLocale());
     }
     Zend_Registry::set('Zend_Locale', $locale);
     $adapter = self::getAdapter();
     $adapter->locale = (string) $locale;
     self::$locale = $locale;
 }