Example #1
0
 /**
  * @param string $key
  * @param Seitenbau\Locale $locale
  * @return string
  */
 protected static function _($key, $locale = null)
 {
     if (is_null($locale)) {
         $locale = Registry::getLocale('Zend_Translate');
     }
     return Registry::get('Zend_Translate')->_($key, $locale);
 }
Example #2
0
 /**
  * @param  string $lang
  * @return void
  */
 protected function setCurrentLang($lang)
 {
     if (empty($lang) || !SbLocale::isLocale($lang, true)) {
         return false;
     }
     $locale = new SbLocale($lang);
     if (!$locale instanceof SbLocale) {
         return false;
     }
     Registry::getLocale()->setLocale($locale);
     $translate = Registry::get('Zend_Translate');
     if ($translate instanceof \Zend_Translate) {
         $translate->setLocale($locale);
     }
     return true;
 }
Example #3
0
 /**
  * @test
  * @group library
  */
 public function setLocaleShouldSetLocale()
 {
     $this->assertInstanceOf('Zend_Locale', Registry::getLocale());
 }
Example #4
0
 /**
  * Gibt die \Seitenbau\Locale zurueck
  * @return \Seitenbau\Locale
  */
 protected static function getLocale($locale = null)
 {
     if ($locale instanceof SbLocale) {
         return $locale;
     }
     if (SbLocale::isLocale($locale)) {
         return new SbLocale($locale);
     }
     $locale = Registry::getLocale();
     if (!is_null($locale)) {
         return $locale;
     }
     return self::getDefaultLocale();
 }
Example #5
0
 protected function _($key, $locale = null)
 {
     if (is_null($locale)) {
         $locale = Registry::getLocale('Zend_Translate');
     }
     return $this->getTranslator()->_($key, $locale);
 }
Example #6
0
 protected function _initTranslator()
 {
     $this->bootstrap('locale');
     $locale = $this->getResource('locale');
     $translationConfig = Registry::getConfig()->translation;
     if (isset($translationConfig->route)) {
         $route = $translationConfig->route->toArray();
     } else {
         $route = array();
     }
     $defaultLocale = Registry::getLocale();
     foreach (array_keys($route) as $routeLangFrom) {
         if (strtolower($routeLangFrom) == strtolower($defaultLocale->toString()) || strtolower($routeLangFrom) == strtolower($defaultLocale->getLanguage())) {
             unset($route[$routeLangFrom]);
         }
     }
     $translate = new \Zend_Translate(array('adapter' => 'Zend_Translate_Adapter_Array', 'content' => $translationConfig->directory, 'scan' => Zend_Translate::LOCALE_DIRECTORY, 'locale' => $locale, 'disableNotices' => APPLICATION_ENV === 'testing' ? false : true, 'route' => $route));
     Registry::set('Zend_Translate', $translate);
 }
Example #7
0
 /**
  * @return string
  */
 protected function getInterfaceLocaleCode()
 {
     return (string) Registry::getLocale();
 }