当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Translate::getAdapter方法代码示例

本文整理汇总了PHP中Zend_Translate::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate::getAdapter方法的具体用法?PHP Zend_Translate::getAdapter怎么用?PHP Zend_Translate::getAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Translate的用法示例。


在下文中一共展示了Zend_Translate::getAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setMessage

 public static function setMessage(Zend_Translate $message)
 {
     if (!$message->getAdapter() instanceof Core_Translate_Message) {
         throw new InvalidArgumentException('O adapter dever ser Core_Translate_Message');
     }
     static::set(static::MESSAGE, $message);
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:7,代码来源:Registry.php

示例2: fileToDbAction

 function fileToDbAction()
 {
     $translator = new Zend_Translate('ini', APPLICATION_PATH . '/languages/tran_en.ini', 'en');
     $data = $translator->getAdapter()->getDataList();
     foreach ($data['en'] as $key => $value) {
         echo " {$key} => {$value}";
         $ln = new Sys_Model_Translation();
         $ln->setKey($key);
         $ln->setEn($value);
         $ln->save();
     }
     /*
     					$translator = new Zend_Translate('ini', APPLICATION_PATH . '/languages/tran_th.ini', 'en');
         				$data = ($translator->getAdapter()->getDataList());
     foreach ($data['en'] as $key => $value){
     	echo " $key => $value";
     	$ln = new Sys_Model_Translation();
     	$ln->setKey($key);
     	$ln->setLanguage('EN');
     	$ln->setValue($value);
     	$ln->save();
     }
     */
     $this->_helper->redirector('index');
     $this->render('blank', null, true);
 }
开发者ID:hugi2002,项目名称:mylibrary,代码行数:26,代码来源:ModelConfigController.php

示例3: setIniFilenameScanTranslator

 public function setIniFilenameScanTranslator($path, $defaultLanguage, $language = null)
 {
     require_once 'Zend/Translate.php';
     $translate = new Zend_Translate(Zend_Translate::AN_INI, $path, $defaultLanguage, array('scan' => Zend_Translate::LOCALE_FILENAME));
     if ($translate->isAvailable($language)) {
         $translate->setLocale($language);
     }
     $this->setTranslator($translate->getAdapter());
 }
开发者ID:sirprize,项目名称:xzend,代码行数:9,代码来源:Translate.php

示例4: getTranslateAdapter

 /**
  * Returns a translate adaptor
  *
  * @return \Zend_Translate_Adapter
  */
 protected function getTranslateAdapter()
 {
     if ($this->translate instanceof \Zend_Translate) {
         return $this->translate->getAdapter();
     }
     if (!$this->translate instanceof \Zend_Translate_Adapter) {
         $this->translate = new \MUtil_Translate_Adapter_Potemkin();
     }
     return $this->translate;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:15,代码来源:ImportLoader.php

示例5: initTranslator

 /**
  * Set a static reference to a global Zend_Translate object
  * usable through self::_() function
  * If called more then one time, from the second call
  * the $translator object will be appended to the previous one
  * @param Zend_Translate $translator
  */
 public static function initTranslator(Zend_Translate $translator)
 {
     //if ( true ) self::$_stringsWriter = new StringsWriter();
     if (is_null(self::$_translator)) {
         self::$_translator = $translator;
         X_Debug::i("Translator enabled");
     } else {
         self::$_translator->getAdapter()->addTranslation($translator);
     }
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:17,代码来源:Env.php

示例6: testSetAdapter

 public function testSetAdapter()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_GETTEXT, dirname(__FILE__) . '/Translate/_files/testmsg_en.mo', 'en');
     $lang->setAdapter(Zend_Translate::AN_ARRAY, array());
     $this->assertTrue($lang->getAdapter() instanceof Zend_Translate_Adapter_Array);
     try {
         $lang->xxxFunction();
         $this->fail("exception expected");
     } catch (Zend_Translate_Exception $e) {
         // success
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:12,代码来源:TranslateTest.php

示例7: setTranslator

 /**
  * Sets a translation Adapter for translation
  *
  * @param  Zend_Translate|Zend_Translate_Adapter $translate
  * @return Zend_View_Helper_HeadTitle
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } elseif ($translate instanceof Zend_Translate) {
         $this->_translator = $translate->getAdapter();
     } else {
         require_once 'Zend/View/Exception.php';
         throw new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
     }
     return $this;
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:18,代码来源:HeadTitle.php

示例8: setTranslator

 /**
  * Sets a translation Adapter for translation
  *
  * @param  Zend_Translate|Zend_Translate_Adapter $translate
  * @return Zend_View_Helper_HeadTitle
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } elseif ($translate instanceof Zend_Translate) {
         $this->_translator = $translate->getAdapter();
     } else {
         $e = new Zend_View_Exception("You must set an instance of Zend_Translate or Zend_Translate_Adapter");
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:19,代码来源:HeadTitle.php

示例9: setTranslator

 /**
  * Set translator
  *
  * @param  Zend_Translate|Zend_Translate_Adapter|null $translator
  * @return Zend_View_Helper_FormElement
  */
 public function setTranslator($translator = null)
 {
     if (null === $translator) {
         $this->_translator = null;
     } elseif ($translator instanceof Zend_Translate_Adapter) {
         $this->_translator = $translator;
     } elseif ($translator instanceof Zend_Translate) {
         $this->_translator = $translator->getAdapter();
     } else {
         $e = new Zend_View_Exception('Invalid translator specified');
         $e->setView($this->view);
         throw $e;
     }
     return $this;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:21,代码来源:FormElement.php

示例10: _scanTranslations

 /**
  * Reads all available component translations and adds them to the translation object
  */
 private function _scanTranslations()
 {
     // check for valid translation object
     if (is_object($this->_translate)) {
         foreach ($this->_extensionRegistry as $component => $settings) {
             // check if component owns translation
             if (isset($settings->languages) && is_readable($settings->path . $settings->languages)) {
                 // keep current locale
                 $locale = $this->_translate->getAdapter()->getLocale();
                 $this->_translate->addTranslation($settings->path . $settings->languages, null, array('scan' => Zend_Translate::LOCALE_FILENAME));
                 // reset current locale
                 $this->_translate->setLocale($locale);
             }
         }
     }
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:19,代码来源:Manager.php

示例11: initTranslateable

 /**
  * Function that checks the setup of this class/traight
  *
  * This function is not needed if the variables have been defined correctly in the
  * source for this object and theose variables have been applied.
  *
  * return @void
  */
 protected function initTranslateable()
 {
     if ($this->translateAdapter instanceof \Zend_Translate_Adapter) {
         // OK
         return;
     }
     if ($this->translate instanceof \Zend_Translate) {
         // Just one step
         $this->translateAdapter = $this->translate->getAdapter();
         return;
     }
     if ($this->translate instanceof \Zend_Translate_Adapter) {
         // It does happen and if it is all we have
         $this->translateAdapter = $this->translate;
         return;
     }
     // Make sure there always is an adapter, even if it is fake.
     $this->translateAdapter = new \MUtil_Translate_Adapter_Potemkin();
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:27,代码来源:Agenda.php

示例12: setup

 /**
  * Setup
  *
  * @return void
  */
 public function setup(Zend_Config $config)
 {
     // Setup Cache
     if ($config->get('cache')) {
         $cache = Zym_Cache::factory('Core');
         Zend_Translate::setCache($cache);
     }
     $adapter = $config->get('adapter');
     $data = $this->_parseDataPath($config->get('data'));
     $locale = $config->get('locale');
     $options = $this->_parseOptions($config->get('options')->toArray());
     $translate = new Zend_Translate($adapter, $data, null, $options);
     // Weird Zend_Translate issues
     // We cannot set a locale in the constructor
     $translate->getAdapter()->setLocale($locale);
     if ((bool) $config->get('registry')->get('enabled')) {
         /**
          * @see Zend_Registry
          */
         require_once 'Zend/Registry.php';
         Zend_Registry::set($config->get('registry')->get('key'), $translate);
     }
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:28,代码来源:Translate.php

示例13: _initTranslation

 /**
  * init translation
  */
 protected function _initTranslation()
 {
     try {
         // init config
         $this->bootstrap('config');
         // init cache
         $this->bootstrap('cache');
         // init session
         $this->bootstrap('session');
         // get config
         $config = Knowledgeroot_Registry::get('config');
         // get cache
         $cache = Knowledgeroot_Registry::get('cache');
         // get session
         $session = new Zend_Session_Namespace('user');
         // check if session has a locale
         $locale = null;
         if (!empty($session->language)) {
             $locale = $session->language;
         } else {
             $locale = $config->base->locale;
         }
         // load translations
         $translate = new Knowledgeroot_Translation();
         $translate->loadTranslations($config->translation->folder);
         $translate->setLocale($locale);
         // save in registry
         Knowledgeroot_Registry::set('translate', $translate);
         // create zend translate object
         $zTranslate = new Zend_Translate(array('adapter' => 'gettext', 'content' => $translate->getLocaleFile(), 'locale' => $translate->getLocale()));
         foreach ($translate->getTranslations() as $key => $value) {
             $zTranslate->getAdapter()->addTranslation(array('adapter' => 'gettext', 'content' => $value, 'locale' => $key, 'clear' => false));
         }
         // set default locale
         $zTranslate->getAdapter()->setLocale($locale);
         // set cache
         $zTranslate->setCache($cache);
         // save in Zend_Translate in registry
         Knowledgeroot_Registry::set('Zend_Translate', $zTranslate);
     } catch (Zend_Exception $e) {
         echo $e->getMessage();
         die('no translation');
     }
 }
开发者ID:asmaklad,项目名称:knowledgeroot,代码行数:47,代码来源:Bootstrap.php

示例14: setTranslator

 /**
  * Sets a translation Adapter for translation
  *
  * @param  Zend_Translate|Zend_Translate_Adapter $translate Instance of Zend_Translate
  * @throws Zend_View_Exception When no or a false instance was set
  * @return Zend_View_Helper_Translate
  */
 public function setTranslator($translate)
 {
     if ($translate instanceof Zend_Translate_Adapter) {
         $this->_translator = $translate;
     } else {
         if ($translate instanceof Zend_Translate) {
             $this->_translator = $translate->getAdapter();
         } else {
             require_once 'Zend/View/Exception.php';
             $e = new Zend_View_Exception('You must set an instance of Zend_Translate or Zend_Translate_Adapter');
             $e->setView($this->view);
             throw $e;
         }
     }
     return $this;
 }
开发者ID:fredcido,项目名称:cenbrap,代码行数:23,代码来源:Translate.php

示例15: setTranslator

 /**
  * Set translation object
  *
  * @param  Zend_Translate|Zend\Translate\Adapter\Adapter|null $translator
  * @return Zend\Filter\InputFilter
  */
 public function setTranslator($translator = null)
 {
     if (null === $translator || $translator instanceof TranslationAdapter) {
         $this->_translator = $translator;
     } elseif ($translator instanceof Translator) {
         $this->_translator = $translator->getAdapter();
     } else {
         throw new Validator\Exception('Invalid translator specified');
     }
     return $this;
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:17,代码来源:InputFilter.php


注:本文中的Zend_Translate::getAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。