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


PHP Zend_Translate::setOptions方法代码示例

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


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

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

示例2: testSettingLogPriorityForLog

 /**
  * @ZF-10051
  */
 public function testSettingLogPriorityForLog()
 {
     $stream = fopen('php://memory', 'w+');
     require_once 'Zend/Log/Writer/Stream.php';
     $writer = new Zend_Log_Writer_Stream($stream);
     require_once 'Zend/Log.php';
     $log = new Zend_Log($writer);
     $lang = new Zend_Translate(array('adapter' => Zend_Translate::AN_CSV, 'content' => dirname(__FILE__) . '/Translate/Adapter/_files', 'locale' => 'en', 'delimiter' => ',', 'logPriority' => 3, 'log' => $log));
     $lang->setLocale('ru');
     rewind($stream);
     $this->assertContains('ERR (3)', stream_get_contents($stream));
     $lang->setOptions(array('logPriority' => 1));
     $lang->setLocale('sv');
     rewind($stream);
     $this->assertContains('ALERT (1)', stream_get_contents($stream));
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:19,代码来源:TranslateTest.php

示例3: testDontLogUntranslatedMessageWithIsTranslated

 /**
  * ZF-7508
  */
 public function testDontLogUntranslatedMessageWithIsTranslated()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_CSV, dirname(__FILE__) . '/Translate/Adapter/_files', 'en', array('delimiter' => ','));
     $this->assertFalse($lang->isTranslated('ignored'));
     $stream = fopen('php://memory', 'w+');
     require_once 'Zend/Log/Writer/Stream.php';
     $writer = new Zend_Log_Writer_Stream($stream);
     require_once 'Zend/Log.php';
     $log = new Zend_Log($writer);
     $lang->setOptions(array('logUntranslated' => true, 'log' => $log));
     $this->assertFalse($lang->isTranslated('ignored'));
     rewind($stream);
     $this->assertNotContains('ignored', stream_get_contents($stream));
 }
开发者ID:travisj,项目名称:zf,代码行数:17,代码来源:TranslateTest.php

示例4: getmypid

$writer = new Zend_Log_Writer_Stream($logfile);
$writer->setFormatter(new Zend_Log_Formatter_Simple('%timestamp% %priorityName% %request% %remote%: %message%' . "\n"));
$filter = new Zend_Log_Filter_Priority((int) $configuration->log->level);
$writer->addFilter($filter);
$logger = new Zend_Log($writer);
$logger->setEventItem('pid', getmypid());
$logger->setEventItem('request', $_SERVER['REQUEST_URI']);
$logger->setEventItem('remote', $_SERVER['REMOTE_ADDR']);
// TRANSLATIONS
$locale = new Zend_Locale();
Zend_Registry::set('Zend_Locale', $locale);
// default language when requested language is not available
$defaultlanguage = 'en';
define('DEFAULT_LANGUAGE', 'en');
$translate = new Zend_Translate('csv', APPLICATION_PATH . '/languages/', null, array('scan' => Zend_Translate::LOCALE_FILENAME));
$translate->setOptions(array('log' => $logger, 'logUntranslated' => true));
if (!$translate->isAvailable($locale->getLanguage())) {
    // not available languages are rerouted to another language
    $translate->setLocale(DEFAULT_LANGUAGE);
}
// REGISTRY - setup the application registry
// An application registry allows the application to store application
// necessary objects into a safe and consistent (non global) place for future
// retrieval.  This allows the application to ensure that regardless of what
// happends in the global scope, the registry will contain the objects it
// needs.
$registry = Zend_Registry::getInstance();
$registry->configuration = $configuration;
$registry->arsConfig = $arsConfig;
$registry->logger = $logger;
$registry->translate = $translate;
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:31,代码来源:bootstrap.php

示例5: _initTranslator

 /**
  * Zend Translate Initialization
  * 
  * First we look the user identity if null, we look the default language from languages.ini
  * 
  * @return Zend_Translate 
  */
 public function _initTranslator()
 {
     // Info Log
     $this->_logging->log('Translator initialized...', Zend_Log::INFO);
     $defaultLanguage = Zend_Auth::getInstance()->hasIdentity() ? Zend_Auth::getInstance()->getIdentity()->language : $this->_config->languages->default;
     $locale = new Zend_Locale($defaultLanguage);
     $translations = APPLICATION_PATH . '/languages/' . $locale . '.php';
     try {
         $translator = new Zend_Translate('array', $translations, $locale);
         // Translation loging enable ?
         if ($this->_config->languages->enableLoging) {
             $translator->setOptions(array('log' => $this->_logging, 'logMessage' => "Missing '%message%' within locale '%locale%'", 'logPriority' => Zend_Log::ALERT, 'logUntranslated' => true));
         }
         Zend_Registry::set('Zend_Translate', $translator);
         return $translator;
     } catch (Zend_Exception $e) {
         // Error Log
         $this->_logging->log('Translations not loading...', Zend_Log::ERR);
         throw new Zend_Translate_Exception('Translations not loading...');
     }
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:28,代码来源:Bootstrap.php


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