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


PHP Zend_Translate_Adapter::translate方法代码示例

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


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

示例1: 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;
 }
开发者ID:bokultis,项目名称:kardiomedika,代码行数:20,代码来源:Db.php

示例2: init

 /**
  * Init default fields for widget form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->translator = Zend_Registry::get('Zend_Translate');
     $this->setTranslator();
     $hId = $this->createElement("hidden", "id")->setOrder($this->order++);
     $this->addElement($hId);
     $wId = $this->createElement("hidden", "wid")->setOrder($this->order++);
     $this->addElement($wId);
     $txtTitle = $this->createElement("text", "title")->setOrder($this->order++)->setLabel("LBL_TITLE")->addFilter('StripTags')->addValidator(new Zend_Validate_LessThan(100))->setRequired(true);
     $this->addElement($txtTitle);
     $rbShowTitle = $this->createElement("radio", "showtitle");
     $rbShowTitle->setRequired(TRUE)->setOrder($this->order++)->setLabel("LBL_SHOWTITLE")->setValue(0)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbShowTitle);
     $cbPosition = $this->createElement("select", "position")->setOrder($this->order++)->setLabel("LBL_POSITION")->setRequired(true);
     $this->addElement($cbPosition);
     $rbPublished = $this->createElement("radio", "published")->setOrder($this->order++)->setLabel("LBL_PUBLISHED")->setValue(1)->setRequired(true)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbRenderFor = $this->createElement("radio", "renderfor")->setOrder($this->order++)->setLabel("MENU_RENDER_FOR")->setValue(0)->setRequired(true)->setMultiOptions(array($this->translator->translate("LBL_ALL"), $this->translator->translate("LBL_SELECTED_ONLY")));
     $this->addElement($rbRenderFor);
     $cbMenuItem = $this->createElement("multiselect", "menuitem")->setOrder($this->order++)->setLabel("MENU_ITEM");
     $this->addElement($cbMenuItem);
     $hMod = $this->createElement("hidden", "mod")->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default');
     $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions);
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setOrder(99999);
     $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper')));
     $btnSubmit->removeDecorator('Label');
     $this->addElement($btnSubmit);
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:43,代码来源:Widget.php

示例3: _nx

 /**
  * Plural translation with context
  *
  * @param string $messageId
  * @param string $pluralId
  * @param int $n
  * @param string $ctxt
  * @return string
  */
 public function _nx($messageId, $pluralId, $n, $ctxt)
 {
     if (null === $this->translate) {
         return $messageId;
     }
     $msgId = $ctxt . chr(4) . $messageId;
     $plrId = $ctxt . chr(4) . $pluralId;
     $txt = $this->translate->translate(array($msgId, $plrId, $n));
     if ($txt == $msgId && !is_null($this->fallback)) {
         $txt = $this->fallback->translate(array($msgId, $plrId, $n));
     }
     return sprintf($txt, $n);
 }
开发者ID:wthielen,项目名称:zf1e,代码行数:22,代码来源:Multilanguage.php

示例4: init

 /**
  * Init default fields for widget form
  * @see Zend_Form::init()
  */
 public function init()
 {
     $this->_addClassNames('well');
     $this->setMethod(Zend_Form::METHOD_POST);
     $this->translator = Zend_Registry::get('Zend_Translate');
     $this->setTranslator();
     $hId = $this->createElement("hidden", "id")->setOrder($this->order++);
     $this->addElement($hId);
     $wId = $this->createElement("hidden", "wid")->setOrder($this->order++);
     $this->addElement($wId);
     $txtTitle = $this->createElement("text", "title")->setOrder($this->order++)->setLabel("LBL_TITLE")->addFilter('StripTags')->addValidator(new Zend_Validate_LessThan(100))->setRequired(true);
     $this->addElement($txtTitle);
     $rbShowTitle = $this->createElement("radio", "showtitle");
     $rbShowTitle->setRequired(TRUE)->setOrder($this->order++)->setLabel("LBL_SHOWTITLE")->setValue(0)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbShowTitle);
     $cbPosition = $this->createElement("select", "position")->setOrder($this->order++)->setLabel("LBL_POSITION")->setRequired(true);
     $this->addElement($cbPosition);
     $rbPublished = $this->createElement("radio", "published")->setOrder($this->order++)->setLabel("LBL_PUBLISHED")->setValue(1)->setRequired(true)->setMultiOptions(array("LBL_NO", "LBL_YES"));
     $this->addElement($rbPublished);
     $rbRenderFor = $this->createElement("radio", "renderfor")->setOrder($this->order++)->setLabel("MENU_RENDER_FOR")->setValue(0)->setRequired(true)->setMultiOptions(array($this->translator->translate("LBL_ALL"), $this->translator->translate("LBL_SELECTED_ONLY")));
     $this->addElement($rbRenderFor);
     $cbMenuItem = $this->createElement("multiselect", "menuitem")->setOrder($this->order++)->setLabel("MENU_ITEM");
     $this->addElement($cbMenuItem);
     $hMod = $this->createElement("hidden", "mod")->setOrder(99998);
     $this->addElement($hMod);
     $token = new Zend_Form_Element_Hash('token');
     $token->setSalt(md5(uniqid(rand(), TRUE)));
     $token->setTimeout(60);
     $token->setDecorators(array('ViewHelper'));
     $this->addElement($token);
     $btnSubmit = $this->createElement('submit', 'submit');
     $btnSubmit->setLabel('LBL_SUBMIT');
     $btnSubmit->removeDecorator('Label');
     $btnSubmit->setAttrib('class', 'btn btn-info');
     $this->addElement($btnSubmit);
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:40,代码来源:Widget.php

示例5: setMessage

 /**
  * setMessage() - method set message and type
  *
  * @param string $type
  * @param string $message
  * @param mixed $value
  * @param int $len
  * @return \Extlib\Controller\Action\Helper\FlashMessage
  */
 public function setMessage($type, $message, $value = null, $len = 25)
 {
     if (!in_array(strtolower($type), self::$_allowedTypes)) {
         throw new \Zend_Controller_Action_Exception('Incorrect type of message!');
     }
     if (!\Zend_Validate::is($len, 'Int')) {
         throw new \Zend_Controller_Action_Exception("Param 'len' must be a int value!");
     }
     if (null !== $this->_translator) {
         $message = $this->_translator->translate($message);
     }
     if (null !== $value) {
         if (strlen($value) > $len) {
             $value = mb_substr($value, 0, $len, 'UTF-8') . '..';
         }
         $message = str_replace(self::VALUE_PATTERN, $value, $message);
     }
     self::$_session->setExpirationHops(1, null, true);
     self::$_session->{$this->_namespace} = array(strtolower($type) => $message);
     self::$_messageAdded = true;
     return $this;
 }
开发者ID:lciolecki,项目名称:zf-extensions-library,代码行数:31,代码来源:FlashMessage.php

示例6: translate

 /**
  * Translate the given string
  *
  * @param  string              $messageId  Original to translate
  * @param  string|Zend_Locale  $locale     OPTIONAL locale/language to translate to
  * @return string
  */
 public function translate($messageId, $locale = null)
 {
     return $this->_adapter->translate($messageId, $locale);
 }
开发者ID:renatosoares,项目名称:blog-zend1,代码行数:11,代码来源:Translate.php

示例7: translate

 /**
  * Adicionado suporte a token
  *
  * @inheridoc
  */
 public function translate($messageId, $locale = null, array $tokens = array())
 {
     $message = parent::translate($messageId, $locale);
     if (null === $locale) {
         $locale = $this->_options['locale'];
     }
     if (!Zend_Locale::isLocale($locale, true, false)) {
         $locale = new Zend_Locale($locale);
     }
     $locale = (string) $locale;
     $exists = count($tokens);
     $startToken = $this->startToken;
     $endToken = $this->endToken;
     if ($this->_options['log']) {
         $regex = '@/' . preg_quote($startToken) . '[a-zA-Z_]' . preg_quote($endToken) . '/@';
         if ($exists && !preg_match($regex, $message)) {
             $this->_log($message, $locale);
         }
     }
     if ($exists) {
         $tempMessage = '';
         foreach ($tokens as $token => $value) {
             if (isset($this->_translate[$locale][$value])) {
                 $value = $this->_translate[$locale][$value];
             }
             $tempMessage = str_replace("{$startToken}{$token}{$endToken}", $value, $message);
         }
         $message = $tempMessage;
     }
     return $message;
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:36,代码来源:Message.php

示例8: translate

 /**
  * Adicionado suporte a token
  *
  * @inheridoc
  */
 public function translate($messageId, $locale = null, array $tokens = array())
 {
     $message = parent::translate($messageId, $locale);
     if (null === $locale) {
         $locale = $this->_options['locale'];
     }
     if (!Zend_Locale::isLocale($locale, true, false)) {
         $locale = new Zend_Locale($locale);
     }
     $locale = (string) $locale;
     $exists = count($tokens);
     if ($this->_options['log']) {
         if ($exists && !preg_match('@/%[a-zA-Z_]%/@', $message)) {
             $this->_log($message, $locale);
         }
     }
     if ($exists) {
         $tempMessage = '';
         foreach ($tokens as $token => $value) {
             if (isset($this->_translate[$locale][$value])) {
                 $value = $this->_translate[$locale][$value];
             }
             $tempMessage = str_replace("%{$token}%", $value, $message);
         }
         var_dump($tempMessage);
         die;
         $message = $tempMessage;
     }
     return $message;
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:35,代码来源:Message.php

示例9: translate

 /**
  * Translates the given string
  * returns the translation
  *
  * @see Zend_Locale
  * @param  string             $sectionId Section string
  * @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
  */
 public function translate($sectionId, $messageId = null, $locale = null)
 {
     if ($messageId == null && $sectionId) {
         $messageId = $sectionId;
         $sectionId = self::$_commonSection;
     }
     $message = $sectionId . '.' . $messageId;
     $translatedMessage = parent::translate($message, $locale);
     if ($translatedMessage == $message) {
         return $messageId;
     }
     return $translatedMessage;
 }
开发者ID:laiello,项目名称:resmania,代码行数:24,代码来源:Text.php


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