本文整理汇总了PHP中Zend_Translate_Adapter类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate_Adapter类的具体用法?PHP Zend_Translate_Adapter怎么用?PHP Zend_Translate_Adapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Translate_Adapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
/**
* Copy from \Zend_Translate_Adapter
*
* Translates the given string
* returns the translation
*
* @param string $text Translation string
* @param string|\Zend_Locale $locale (optional) Locale/Language to use, identical with locale
* identifier, @see \Zend_Locale for more information
* @return string
*/
public function _($text, $locale = null)
{
if (!$this->translateAdapter) {
$this->initTranslateable();
}
return $this->translateAdapter->_($text, $locale);
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: getTranslate
/**
* Retrieve translate object
*
* @throws Zend_Application_Resource_Exception if registry key was used
* already but is no instance of Zend_Translate
* @return Zend_Translate
*/
public function getTranslate()
{
if (null === $this->_translate) {
$this->buildLog();
// retrieve cache if requested
if (isset($this->_options['cacheEnabled']) && $this->_options['cacheEnabled']) {
// check for cachemanager in bootstrap
if (!$this->getBootstrap()->hasPluginResource('cachemanager')) {
throw new Zend_Application_Resource_Exception("You must configure the cachemanager with " . "the key {$this->getCacheKey()}");
}
// bootstrap the cachemanager and retrieve it
/** @var $cacheManager Zend_Cache_Manager */
$cacheManager = $this->getBootstrap()->bootstrap('cachemanager')->getResource('cachemanager');
// check for the given key
if (!$cacheManager->hasCache($this->getCacheKey())) {
throw new Zend_Application_Resource_Exception("You must configure the cachemanager with " . "the key {$this->getCacheKey()}");
}
// set cache for translator
Zend_Translate_Adapter::setCache($cacheManager->getCache($this->getCacheKey()));
}
// fetch translate object into local variable
$this->_translate = parent::getTranslate();
}
return $this->_translate;
}
示例6: tearDown
protected function tearDown()
{
// restore static variables
if (isset($this->cache)) {
Zend_Translate_Adapter::setCache($this->cache);
unset($this->cache);
} else {
Zend_Translate_Adapter::removeCache();
}
// unset the registry
Zend_Registry::_unsetInstance();
}
示例7: _
/**
* proxy for easy access to translations
*
* @param string $messageId Translation string
* @param string|\Zend_Locale $locale (optional) Locale/Language to use, identical with locale
* identifier, @see \Zend_Locale for more information
* @return string
*/
private function _($messageId, $locale = null)
{
if ($this->translate) {
return $this->translate->_($messageId, $locale);
}
return $messageId;
}
示例8: afterRegistry
public function afterRegistry()
{
parent::afterRegistry();
$this->setIfExists('gof_form_id', 'label', $this->translate->_('FormID'));
$this->setIfExists('gof_form_version', 'label', $this->translate->_('Version'));
$this->setIfExists('gof_form_title', 'label', $this->translate->_('Name'));
$this->setIfExists('gof_form_active', 'label', $this->translate->_('Active'), 'elementClass', 'checkbox');
}
示例9: testDiffReadableBeforeAndAfterLocalised
public function testDiffReadableBeforeAndAfterLocalised()
{
$this->translate->setLocale('nl');
$this->object = new \MUtil_Date('2010-05-13 12:00:00');
$testDate = new \MUtil_Date('2010-05-13 12:00:10');
$this->assertEquals('10 seconden geleden', $this->object->diffReadable($testDate, $this->translate));
$testDate = new \MUtil_Date('2010-05-13 11:59:50');
$this->assertEquals('over 10 seconden', $this->object->diffReadable($testDate, $this->translate));
$testDate = new \MUtil_Date('2010-05-13 12:00:00');
$this->assertEquals('over 0 seconden', $this->object->diffReadable($testDate, $this->translate));
}
示例10: _addElementPerson
private function _addElementPerson()
{
$translate = Zend_Registry::get("Zend_Translate");
$url = new Zend_View_Helper_Url();
$urlSearch = $url->url(array('module' => 'persons', 'controller' => 'person', 'action' => 'search-form'), null, true);
$urlNew = $url->url(array('module' => 'persons', 'controller' => 'person', 'action' => 'create'), null, true);
$append = '';
if ($this->_action == self::ACTION_ADD) {
$append .= '<a id="btnPersonSearch" href="' . $urlSearch . '" ' . ' rel="colorbox-search" search-return-id="id" search-return-value="person_name">' . '<i class="icon-search" rel="tooltip" data-original-title="' . $this->translate->_("Search person") . '"></i>' . '</a>';
}
$this->addElement('text', 'person_name', array('label' => 'Person', 'value' => $this->_model ? $this->_model->getPerson()->getName() : '', 'dimension' => 6, 'disabled' => true, 'placeholder' => $translate->_('Use the links aside to search a person or create a new one'), 'append' => $append . ' | ' . '<a class="hide" id="btnPersonDetails" href="#" rel="colorbox-details">' . $this->translate->_("Details") . '</a>' . ' | ' . '<a class="hide" id="btnPersonCreate" href="' . $urlNew . '" rel="colorbox">' . '<i class="icon-plus-sign" rel="tooltip" data-original-title="' . $this->translate->_("Add new") . ' ' . $this->translate->_("person") . '"></i>' . '</a>'));
}
示例11: __construct
/**
* Generates the adapter
*
* @param string $data Translation data
* @param string|Zend_Locale $locale OPTIONAL Locale/Language to set, identical with locale identifier,
* see Zend_Locale for more information
* @param array $options Options for this adapter
*/
public function __construct($data, $locale = null, array $options = array())
{
$this->_options['delimiter'] = ";";
$this->_options['length'] = 0;
$this->_options['enclosure'] = '"';
parent::__construct($data, $locale, $options);
}
示例12: __construct
/**
* Generates the adapter
*
* @param array $db The DB connection
* @param string|Zend_Locale $locale OPTIONAL Locale/Language to set, identical with locale identifier,
* see Zend_Locale for more information
* @param array $options OPTIONAL Options to set
*/
public function __construct($db, $locale = null, array $options = array())
{
// If $db is null: nothing to do.
if ($db == null) {
return;
}
// Keep the db reference for possible use
$this->db = $db;
// Check whether the view system is PHPLIB. In yes we
// add all the translations as entities in the view object
// Get the utilitary objects from the registry
$registry = Zend_registry::getInstance();
$zmax_context = $registry->get("zmax_context");
$config = $zmax_context->config;
// By default we take the zmax context view, unless it is explicitly given
if (isset($options['view'])) {
$this->phplib_view = $options['view'];
} else {
if ($config->view->zmax_view_system == "phplib") {
$this->phplib_view = $zmax_context->view;
}
}
// Now call the parent constructor
// Adding this option is necessary starting with Zend 1.6, to prevent
// an ugly message
$options['disableNotices'] = 'true';
parent::__construct($db, $locale, $options);
}
示例13: __construct
/**
* Generates the adapter
*
* @param array|Zend_Config $options Translation content
*/
public function __construct($options = array())
{
$this->_options['delimiter'] = ";";
$this->_options['length'] = 0;
$this->_options['enclosure'] = '"';
if ($options instanceof Zend_Config) {
$options = $options->toArray();
} else {
if (func_num_args() > 1) {
$args = func_get_args();
$options = array();
$options['content'] = array_shift($args);
if (!empty($args)) {
$options['locale'] = array_shift($args);
}
if (!empty($args)) {
$opt = array_shift($args);
$options = array_merge($opt, $options);
}
} else {
if (!is_array($options)) {
$options = array('content' => $options);
}
}
}
parent::__construct($options);
}
示例14: __construct
public function __construct($locale)
{
if (!$locale instanceof Zend_Locale) {
$locale = new Zend_Locale($locale);
}
$locale = (string) $locale;
parent::__construct(array("locale" => $locale, "content" => array("__pimcore_dummy" => "only_a_dummy")));
}
示例15: translate
/**
* Translates the given string
* returns the translation
*
* @see Zend_Locale
* @param string|array $messageId Translation string, or Array for plural translations
* @param string|Zend_Locale $locale (optional) Locale/Language to use, identical with
* locale identifier, @see Zend_Locale for more information
* @param string $section
* @return string
*/
public function translate($messageId, $locale = null, $section = 'global')
{
$this->_logSection = $section;
$translated = parent::translate($messageId, $locale);
if ($translated == '') {
return $messageId;
}
return $translated;
}