• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Translate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     //set lang var to session
     $nsLang = new Zend_Session_Namespace("Language");
     $lang = "vi";
     if ($request->getParam("lang") != "") {
         $lang = $request->getParam("lang");
     } else {
         if ($nsLang->language != "") {
             $lang = $nsLang->language;
         }
     }
     $nsLang->language = $lang;
     //Set back to session
     $options = array('disableNotices' => true, 'logUntranslated' => false);
     $commonLang = new Zend_Translate("tmx", APP_PATH . "/languages/common.tmx", $lang, $options);
     $controller = $request->getControllerName();
     $langPath = APP_PATH . "/languages/" . $controller . ".tmx";
     if (file_exists($langPath)) {
         $commonLang->addTranslation($langPath, $lang);
     }
     $registry = Zend_Registry::getInstance();
     $registry->set("translate", $commonLang);
     return $lang;
 }
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:25,代码来源:Lang.php


示例2: _initSetTranslations

 protected function _initSetTranslations()
 {
     $translate = new Zend_Translate(array('adapter' => 'gettext', 'content' => APPLICATION_PATH . '/../library/Rdine/Translate/Language', 'locale' => null, 'scan' => Zend_Translate::LOCALE_FILENAME));
     $namespace = new Zend_Session_Namespace();
     $language = 'en';
     if ($namespace->lang) {
         if ($namespace->lang == 'en_US') {
             $language = 'en';
             $namespace->lang = 'en_US';
         }
         if ($namespace->lang == 'es_SP') {
             $language = 'es_SP';
         }
     } else {
         $language = 'en';
         $namespace->lang = 'en_US';
     }
     $translate->setLocale($language);
     $view = $this->getResource('view');
     $view->translate = $translate;
     if ($namespace->lang) {
         $view->lang = $namespace->lang;
     } else {
         $view->lang = 'en_US';
         $namespace->lang = 'en_US';
     }
 }
开发者ID:nightraiser,项目名称:rdine,代码行数:27,代码来源:Bootstrap.php


示例3: getMessages

 public function getMessages(\Zend_Translate $t)
 {
     if ($this->checkedRespondentTracks) {
         $messages[] = sprintf($t->_('Checked %d tracks.'), $this->checkedRespondentTracks);
     }
     if ($this->checkedTokens || !$this->checkedRespondentTracks) {
         $messages[] = sprintf($t->_('Checked %d tokens.'), $this->checkedTokens);
     }
     if ($this->hasChanged()) {
         if ($this->surveyCompletionChanges) {
             $messages[] = sprintf($t->_('Answers changed by survey completion event for %d tokens.'), $this->surveyCompletionChanges);
         }
         if ($this->resultDataChanges) {
             $messages[] = sprintf($t->_('Results and timing changed for %d tokens.'), $this->resultDataChanges);
         }
         if ($this->roundCompletionChanges) {
             $messages[] = sprintf($t->_('%d token round completion events caused changed to %d tokens.'), $this->roundCompletionCauses, $this->roundCompletionChanges);
         }
         if ($this->tokenDateChanges) {
             $messages[] = sprintf($t->_('%2$d token date changes in %1$d tracks.'), $this->tokenDateCauses, $this->tokenDateChanges);
         }
         if ($this->roundChangeUpdates) {
             $messages[] = sprintf($t->_('Round changes propagated to %d tokens.'), $this->roundChangeUpdates);
         }
         if ($this->deletedTokens) {
             $messages[] = sprintf($t->_('%d tokens deleted by round changes.'), $this->deletedTokens);
         }
         if ($this->createdTokens) {
             $messages[] = sprintf($t->_('%d tokens created to by round changes.'), $this->createdTokens);
         }
     } else {
         $messages[] = $t->_('No tokens were changed.');
     }
     return $messages;
 }
开发者ID:harmslijper,项目名称:gemstracker-library,代码行数:35,代码来源:ChangeTracker.php


示例4: _loadFromFiles

 /**
  * @param array $files
  */
 protected function _loadFromFiles(array $files)
 {
     $translate = new Zend_Translate('Array', $files['en'], 'en');
     /** @var Zend_Translate_Adapter_Array $translate */
     $translate->addTranslation(array('content' => $files['nl'], 'locale' => 'nl'));
     return $translate;
 }
开发者ID:WebSpider,项目名称:OpenConext-engineblock,代码行数:10,代码来源:CacheProxy.php


示例5: preDispatch

 public function preDispatch($request)
 {
     try {
         $locale = new Zend_Locale();
         $locale->setDefault('en');
         $locale->setLocale(Zend_Locale::BROWSER);
         $requestedLanguage = key($locale->getBrowser());
         $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
         $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'translations.log');
         $writer->setFormatter($formatter);
         $logger = new Zend_Log($writer);
         $frontendOptions = array('cache_id_prefix' => 'translation', 'lifetime' => 86400, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => APPLICATION_CACHE_PATH);
         $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         $options = array('adapter' => 'gettext', 'scan' => Zend_Translate::LOCALE_FILENAME, 'content' => APPLICATION_PATH . '/languages/en/en.mo', 'locale' => 'auto', 'disableNotices' => true);
         $translate = new Zend_Translate($options);
         if (!$translate->isAvailable($locale->getLanguage())) {
             $locale->setLocale('en');
         } else {
             $translate->setLocale($locale);
         }
         $translate->setCache($cache);
         Zend_Registry::set('locale', $locale->getLanguage());
         Zend_Registry::set('Zend_Translate', $translate);
     } catch (Exception $e) {
         try {
             $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugin-locale.log');
             $logger = new Zend_Log($writer);
             $logger->log($e->getMessage(), Zend_Log::ERR);
         } catch (Exception $e) {
         }
     }
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:33,代码来源:Locale.php


示例6: getValues

 public static function getValues(Zend_Translate $lang)
 {
     $countries = Zend_Locale::getTranslationList('Territory', $lang->getLocale(), 2);
     $continents = Zend_Locale::getTranslationList('Territory', $lang->getLocale(), 1);
     array_unshift($countries, current($continents));
     return $countries;
 }
开发者ID:HardSkript,项目名称:unsee.cc,代码行数:7,代码来源:Countries.php


示例7: 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


示例8: 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


示例9: _

/**
 * Hook for SECTION: i18n (translation)
 */
function _($msg)
{
    /////////////////////////////
    // ==> SECTION: i18n <==
    // Need volunteers to help create translations for the catalog in data/zfdemo.mo
    // Nice tool to help manage the gettext catalog: http://www.poedit.net/
    static $translator = null;
    if ($translator === null) {
        require_once 'Zend/Translate.php';
        $registry = Zend_Registry::getInstance();
        $translator = new Zend_Translate('gettext', $registry['dataDir'] . 'zfdemo.mo', $registry['userLocale']);
    }
    if (func_num_args() === 1) {
        return $translator->_($msg);
    } else {
        $args = func_get_args();
        array_shift($args);
        return vsprintf($translator->_($msg), $args);
    }
    /////////////////////////////
    // ==> SECTION: mvc <==
    if (func_num_args() === 1) {
        return $msg;
    } else {
        $args = func_get_args();
        array_shift($args);
        return vsprintf($msg, $args);
    }
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:32,代码来源:index.php


示例10: translate

	static function translate($locale_code, $module_name, $key, $replace = null, $do_translation = true) {

// DON'T EVER LEAVE THIS UNCOMMENTED
// ob_clean();
// can be useful for debugging since using dd() will dump out into the existing markup and be hard to see
// but this clears out all the other markup so the debug data can be seen clearly

		$translation = $key;
		if ($do_translation) {
			if (RivetyCore_Registry::get('enable_localization') == '1'
			 && !is_null($module_name) && trim($module_name) != ""
			 && !is_null($key) && trim($key) != "") {
				$locale_code = RivetyCore_Translate::cleanZendLocaleCode($locale_code);

				// TODO: account for core rivety module
				$path_to_csv = RivetyCore_Registry::get('basepath')."/modules/".$module_name."/languages/".$locale_code.".csv";

				if (file_exists($path_to_csv)) {
					try {
						$translate = new Zend_Translate("csv", $path_to_csv, $locale_code, array('delimiter' => ","));
						$translation = $translate->_($key);
						// this next bit will populate the locale file with untranslated terms
						// so it's easier for someone to go through and translate them
						if (RivetyCore_Registry::get('auto_populate_language_files') == '1') {
							if (!$translate->isTranslated($key, true, $locale_code)) {
								$key_no_quotes = str_replace('"', '&quot;', $key);
								$str = '"'.$key_no_quotes.'","'.$key_no_quotes.'"'."\n";
								file_put_contents($path_to_csv, $str, FILE_APPEND);
							}
						}
					} catch (Exception $e) {
						$translation = $key;
					}
				} else {
					// create the file
					file_put_contents($path_to_csv, $key.','.$key);
				}
			}
		}
		$output = "";
		if (is_null($replace)) {
			// no replace, no sprintf
			$output = $translation;
		} else {
			if (is_array($replace)) {
				if (count($replace) > 1) {
					// there are multiple indices, use vsprintf
					$output = vsprintf($translation, $replace);
				} else {
					// there's only one index, use the cheaper sprintf instead
					$output = sprintf($translation, $replace[0]);
				}
			} else {
				// $replace is not an array, so try using it straight
				$output = sprintf($translation, $replace);
			}
		}
		return $output;
	}
开发者ID:richjoslin,项目名称:rivety,代码行数:59,代码来源:Translate.php


示例11: _initTranslate

 protected function _initTranslate()
 {
     $registry = Zend_Registry::getInstance();
     $this->_translate = $registry->get('Zend_Translate');
     $this->_translate->addTranslation(array('adapter' => 'array', 'content' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'locales', 'scan' => Zend_Translate::LOCALE_DIRECTORY));
     $registry->set('Zend_Translate', $this->_translate);
     return $registry;
 }
开发者ID:brunopbaffonso,项目名称:ongonline,代码行数:8,代码来源:Bootstrap.php


示例12: _initTranslation

 protected function _initTranslation()
 {
     $translate = new Zend_Translate('Array', APPLICATION_PATH . '/configs/languages/pt_BR.php', 'pt_BR');
     $translate->setLocale('pt_BR');
     Zend_Registry::set('Zend_Translate', $translate);
     $locale = new Zend_Locale('pt_BR');
     Zend_Registry::set('Zend_Locale', $locale);
 }
开发者ID:victorluissantos,项目名称:Sua-escolha,代码行数:8,代码来源:Bootstrap.php


示例13: _initTranslate

 protected function _initTranslate()
 {
     $translate = new Zend_Translate('gettext', APPLICATION_PATH . '/data/languages/zh.mo', 'zh');
     $translate->addTranslation(APPLICATION_PATH . '/data/languages/en.mo', 'en');
     //$translate->setLocale('zh');
     $translate->setLocale('en');
     Zend_Registry::set('translate', $translate);
 }
开发者ID:sandin,项目名称:iMemo,代码行数:8,代码来源:Bootstrap.php


示例14: _getGettextFileData

 /**
  * get translation with Zend_Translate_Adapter_Gettext
  *
  * @see Zend_Translate_Adapter_Gettext
  * @param string $file
  * @return array
  */
 protected function _getGettextFileData($file)
 {
     $data = array();
     if (file_exists($file)) {
         $gettextTranslator = new Zend_Translate(array('adapter' => 'Zend_Translate_Adapter_Gettext', 'content' => $file));
         $data = $gettextTranslator->getMessages();
     }
     return $data;
 }
开发者ID:hhirsch,项目名称:LocaleFallback,代码行数:16,代码来源:Translate.php


示例15: routeShutdown

 /**	@brief Changement de langue.
  * 
  * Exploitation du cache de l'application pour stocker l'instance de Zend_Translate correspondant.
  * Si le cache n'est pas présent, une nouvelle instance est créée, puis stockée dans le cache de Zend_Translate.
  * 
  * @see		Controller/Plugin/Zend_Controller_Plugin_Abstract::routeShutdown()
  * @throws	exception Projet_Exception en cas d'erreur au cours de la requête.
  * @return	void.
  */
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     parent::routeShutdown($request);
     // Récupération du paramètre de langue passée dans l'URL
     $sLocal = $this->getRequest()->getParam('language') ? $this->getRequest()->getParam('language') : self::DEFAULT_LANGUAGE;
     // Récupération du local dans une combinaison du type "fr_FR"
     $aLanguage = explode("_", $sLocal);
     $sLanguage = isset($aLanguage[0]) ? $aLanguage[0] : self::DEFAULT_LANGUAGE;
     # Récupération de "fr"
     $sCountry = isset($aLanguage[1]) ? $aLanguage[1] : self::DEFAULT_COUNTRY;
     # Récupération de "FR"
     // Fonctionnalité réalisée si le fichier de langue n'existe pas
     if (!file_exists(LANGUAGE_PATH . $sLanguage . '.ini')) {
         $sLanguage = self::DEFAULT_LANGUAGE;
     }
     // Récupération du cache de la langue en cours dans le cache de Zend_Translate
     if ((bool) APP_CACHE) {
         $oCacheTranslate = Zend_Translate::getCache();
         $oTranslate = $oCacheTranslate->load($sLanguage);
     } else {
         $oTranslate = null;
     }
     // Fonctionnalité réalisé si
     if (empty($oTranslate)) {
         // Initialisation de la langue
         try {
             // Chargement du Zend_Translate
             $oTranslate = new Zend_Translate(array('adapter' => 'ini', 'content' => LANGUAGE_PATH . $sLanguage . '.ini', 'locale' => $sLocal));
             $sFichier = LANGUAGE_PATH . $sLanguage . '.php';
             if (file_exists($sFichier)) {
                 //traduction des erreurs de formulaires
                 $oTranslate->addTranslation(array('content' => new Zend_Translate('array', $sFichier, $sLanguage)));
             }
             if ((bool) APP_CACHE) {
                 // Enregistrement de la langue dans le cache
                 $oCacheTranslate = Zend_Translate::getCache();
                 $oCacheTranslate->save($oTranslate, $sLanguage);
             }
         } catch (Exception $e) {
             if ((bool) APP_CACHE) {
                 // Suppression du cache
                 $oCacheTranslate->remove($sLanguage);
             }
             // Création d'une exception au niveau du projet
             die($e->getMessage());
             throw new Projet_Exception($e->getMessage(), __METHOD__, $e);
         }
     }
     // Enregistrement du Zend_Translate dans les fonctionnalités de l'application
     Zend_Registry::set("Zend_Locale", $sLocal);
     Zend_Registry::set("Zend_Translate", $oTranslate);
     // Potentiellement inutile vu la ligne précédente...
     Zend_Form::setDefaultTranslator($oTranslate);
     Zend_Validate_Abstract::setDefaultTranslator($oTranslate);
     // Language par défaut pour toutes les routes
     Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('language', $sLocal);
 }
开发者ID:netixx,项目名称:Stock,代码行数:66,代码来源:Translate.php


示例16: 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


示例17: _initLanguage

 protected function _initLanguage()
 {
     try {
         $translate = new Zend_Translate('csv', APPLICATION_PATH . '/languages/en.csv', 'en');
         $translate->addTranslation(APPLICATION_PATH . '/languages/br.csv', 'br');
         Zend_Registry::set('Zend_Translate', $translate);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:erickosma,项目名称:e-ong,代码行数:10,代码来源:Bootstrap.php


示例18: _initTranslation

 /**
  * Initialize translation-handling
  *
  * @return void
  */
 protected function _initTranslation()
 {
     $translate = new Zend_Translate('xliff', APPLICATION_PATH . DIRECTORY_SEPARATOR . 'locale', null, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     // Eine Log Instanz erstellen
     $writer = new Zend_Log_Writer_Stream(realpath(APPLICATION_PATH . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'log') . DIRECTORY_SEPARATOR . date('Ymd') . '-TranslateError.log');
     $log = new Zend_Log($writer);
     //
     // Diese der Übersetzungs-Instanz hinzufügen
     $translate->setOptions(array('log' => $log, 'logUntranslated' => true));
     Zend_Registry::set('Zend_Translate', $translate);
 }
开发者ID:heiglandreas,项目名称:gallery,代码行数:16,代码来源:Bootstrap.php


示例19: setUp

 /**
  * Setup test
  *
  * @return void
  */
 public function setUp()
 {
     // Backup server array
     $this->_server = $_SERVER;
     // Clean host env
     unset($_SERVER['HTTP_HOST'], $_SERVER['HTTPS'], $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']);
     // Set translator
     $translator = new Zend_Translate('array', array('foo' => 'en_foo', 'bar' => 'en_bar'), 'en');
     $translator->addTranslation(array('foo' => 'de_foo', 'bar' => 'de_bar'), 'de');
     $translator->setLocale('en');
     Zend_Registry::set('Zend_Translate', $translator);
 }
开发者ID:netvlies,项目名称:zf,代码行数:17,代码来源:RouteTest.php


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Translate_Adapter类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Tool_Project_Provider_View类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap