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


PHP Zend_Translate::translate方法代码示例

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


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

示例1: buildCancelLink

 /**
  * Vytvari "or Cancel" odkaz za tlacitkem
  *
  * @return string
  */
 public function buildCancelLink()
 {
     $cancel = $this->getOption('cancel');
     if (!is_null($cancel)) {
         $request = Zend_Controller_Front::getInstance()->getRequest();
         $projekt = $request->getParam('projekt');
         if (!is_null($projekt)) {
             $projekt = '/' . $projekt;
         }
         return ' ' . $this->_translator->translate('or') . ' <a href="' . $projekt . '/' . $cancel . '" class="cancel">' . $this->_translator->translate('Cancel') . '</a>';
     }
 }
开发者ID:besters,项目名称:My-Base,代码行数:17,代码来源:Submit.php

示例2: _translate

 private function _translate($text)
 {
     if ($this->_options['translate'] === true && null !== $this->_translate) {
         return $this->_translate->translate($text);
     }
     return $text;
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:7,代码来源:Message.php

示例3: translate

 /**
  * Retturn translation string
  * example $l->translate('Field %1 is incorrect', 'FieldName');
  *
  * @param string $msg Message to transalte.
  */
 public function translate($msg)
 {
     $translated = $msg;
     if ($this->translate->isTranslated($msg, true, $this->locale)) {
         $translated = $this->translate->translate($msg);
     } else {
         foreach ($this->translationsPaths as $name => $value) {
             if (!$this->translate->isAvailable($name)) {
                 try {
                     $this->translate->addTranslation($this->translationsPaths[$name], $name);
                     $this->translate->setLocale($this->getLocale());
                 } catch (Zend_Translate_Exception $e) {
                     continue;
                 }
             }
             if ($this->translate->isTranslated($msg, $name)) {
                 $translated = $this->translate->translate($msg, $name);
                 break;
             }
         }
     }
     if (func_num_args() > 1) {
         $params = func_get_args();
         $params[0] = $translated;
         $translated = @call_user_func_array("sprintf", $params);
         //add shield for incorrect translations(warning about incorrect number of arguments)
     }
     return $translated;
 }
开发者ID:pansot2,项目名称:PadCMS-backend,代码行数:35,代码来源:Localizer.php

示例4: getMessage

 private function getMessage($message)
 {
     if ($this->translator) {
         return $this->translator->translate($message);
     } else {
         return $message;
     }
 }
开发者ID:dafik,项目名称:dfi,代码行数:8,代码来源:Adapter.php

示例5: testTranslationOfNoteVisibilityValues

 public function testTranslationOfNoteVisibilityValues()
 {
     $model = new Opus_Note();
     $values = $model->getField('Visibility')->getDefault();
     foreach ($values as $value) {
         $key = $this->helper->getKeyForValue('Opus_Note', 'Visibility', $value);
         $this->assertNotEquals($key, $this->translate->translate($key), 'Translation key \'' . $key . '\' is missing.');
     }
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:9,代码来源:TranslationTest.php

示例6: getValues

 public static function getValues(Zend_Translate $lang)
 {
     $vars = Unsee_Hash::$ttlTypes;
     $values = array();
     foreach ($vars as $item) {
         $elLangString = 'settings_delete_ttl_' . $item;
         if ($lang->isTranslated($elLangString)) {
             $values[$item] = $lang->translate($elLangString);
         }
     }
     return $values;
 }
开发者ID:HardSkript,项目名称:unsee.cc,代码行数:12,代码来源:Delete.php

示例7: testTranslate

 public function testTranslate()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1 (en)'), 'en');
     $lang->addTranslation('ru', array('msg1' => 'Message 1 (ru)'));
     $this->assertEquals($lang->_('msg1'), 'Message 1 (en)');
     $this->assertEquals($lang->_('msg1', 'ru'), 'Message 1 (ru)');
     $this->assertEquals($lang->_('msg2'), 'msg2');
     $this->assertEquals($lang->_('msg2', 'ru'), 'msg2');
     $this->assertEquals($lang->translate('msg1'), 'Message 1 (en)');
     $this->assertEquals($lang->translate('msg1', 'ru'), 'Message 1 (ru)');
     $this->assertEquals($lang->translate('msg2'), 'msg2');
     $this->assertEquals($lang->translate('msg2', 'ru'), 'msg2');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:TranslateTest.php

示例8: testDoubleReroutingForTranslations

 /**
  * @group ZF-2736
  */
 public function testDoubleReroutingForTranslations()
 {
     $translate = new Zend_Translate(array('adapter' => Zend_Translate::AN_ARRAY, 'content' => dirname(__FILE__) . '/Translate/Adapter/_files/testarray/', 'locale' => 'auto', 'scan' => Zend_Translate::LOCALE_FILENAME, 'ignore' => array('.', 'ignoreme', 'LC_TEST'), 'route' => array('ja' => 'en_US', 'en_US' => 'ja')));
     $translate2 = new Zend_Translate(array('adapter' => Zend_Translate::AN_CSV, 'content' => dirname(__FILE__) . '/Translate/Adapter/_files/translation_en.csv', 'locale' => 'en_US'));
     $translate->addTranslation($translate2);
     $langs = $translate->getList();
     $this->assertFalse(array_key_exists('de_DE', $langs));
     $this->assertTrue(array_key_exists('ja', $langs));
     $this->assertTrue(array_key_exists('en_US', $langs));
     $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
     $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:15,代码来源:TranslateTest.php

示例9: testWithOption

 public function testWithOption()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_CSV, dirname(__FILE__) . '/Translate/_files/translation_en2.csv', 'en', array('separator' => ','));
     $this->assertEquals('Message 1 (en)', $lang->translate('Message 1'));
     $this->assertEquals('Message 4 (en)', $lang->translate('Message 4,'));
     $this->assertEquals('Message 5, (en)', $lang->translate('Message 5'));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:TranslateTest.php

示例10: _getButton

 /**
  * Returns HTML for the specified button type.
  *
  * @param int   $type    the button type
  * @param array $options button options
  *
  * @return string
  */
 private function _getButton($type, $options = array())
 {
     if ($type == self::SEPARATOR) {
         return '<a class="button separator"></a>';
     } else {
         if (array_key_exists($type, $this->_defaultButtons)) {
             $options = array_merge($this->_defaultButtons[$type], $options);
         } else {
             if (empty($options)) {
                 throw new OntoWiki_Exception("Missing options for button '{$type}'.");
             }
             if (!array_key_exists('name', $options)) {
                 $options['name'] = $type;
             }
         }
     }
     // translate name
     if (array_key_exists('name', $options)) {
         if ($this->_translate instanceof Zend_Translate) {
             $label = $this->_translate->translate($options['name']);
         } else {
             $label = $options['name'];
         }
     } else {
         $label = null;
     }
     // set class
     if (array_key_exists('+class', $options)) {
         $addedClasses = $options['+class'];
     }
     // set class
     if (array_key_exists('class', $options)) {
         $class = $options['class'];
         if (isset($addedClasses)) {
             $class = $class . ' ' . $addedClasses;
         }
     } else {
         if (isset($addedClasses)) {
             $class = $addedClasses;
         } else {
             $class = null;
         }
     }
     // set id
     if (array_key_exists('id', $options)) {
         $id = 'id="' . $options['id'] . '"';
     } else {
         $id = null;
     }
     if (array_key_exists('url', $options)) {
         $href = 'href="' . $options['url'] . '"';
     } else {
         $href = null;
     }
     if (array_key_exists('title', $options)) {
         $title = 'title="' . $options['title'] . '"';
     } else {
         $title = null;
     }
     // set image
     if (array_key_exists('image_url', $options)) {
         $image = $options['image_url'];
     } else {
         if (array_key_exists('image', $options)) {
             $image = $this->_themeUrlBase . 'images/icon-' . $options['image'] . '.png';
         } else {
             $image = null;
         }
     }
     // construct button link
     $button = sprintf('<a class="button %s" %s %s %s><img src="%s"/><span>&nbsp;%s</span></a>', $class, $id, $href, $title, $image, $label);
     return $button;
 }
开发者ID:dmj,项目名称:uni-helmstedt.hab.de,代码行数:81,代码来源:Toolbar.php

示例11: array

global $errors, $locale, $languages;
// autoloader for zend classes
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Zend');
// prepare language object
if (isset($_POST['language'])) {
    $currentLang = $_POST['language'];
} else {
    $currentLang = 'en';
}
$locale = new Zend_Translate('csv', 'application/locale', 'en', array('scan' => Zend_Translate::LOCALE_DIRECTORY, 'delimiter' => "|"));
// get languages
$languages = array();
foreach ($locale->getList() as $lang) {
    $languages[$lang] = $locale->translate($lang);
}
// set language
try {
    $languageLocale = new Zend_Locale(Zend_Locale::BROWSER);
    if (in_array($languageLocale->getLanguage(), $locale->getList())) {
        $currentLang = $languageLocale->getLanguage();
        $locale->setLocale($languageLocale);
    }
} catch (Exception $e) {
    $currentLang = 'en';
    $locale->setLocale(new Zend_Locale('en'));
}
// get config
$configDist = new Zend_Config_Ini(CONFIG_DIST_PATH);
//
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:31,代码来源:install.php

示例12: translate

 /**
  * Translates the given string.
  * @param  string   message
  * @param  int      plural count
  * @return string
  */
 public function translate($message, $count = NULL)
 {
     return parent::translate($message);
 }
开发者ID:vrana,项目名称:nette,代码行数:10,代码来源:localization.php

示例13: timeDiff

 private static function timeDiff($dateFirst, $dateLast, $limitReturnChunks = 1, Zend_Translate $translator = null, $lang = 'en', $units = self::DEFAULT_UNITS, $precision = 0.25)
 {
     $timeFirst = strtotime($dateFirst);
     $timeLast = strtotime($dateLast);
     $diff = abs($timeLast - $timeFirst);
     $rest = $diff;
     $restChunks = $limitReturnChunks;
     if (strpos($units, 'y') !== false) {
         $years = floor($rest / self::YEAR);
         if ($restChunks <= 1 && ($rest - $years * self::YEAR) / $diff > $precision) {
             $years = 0;
         } else {
             $restChunks--;
         }
         $rest = $rest - $years * self::YEAR;
     } else {
         $years = 0;
     }
     if (strpos($units, 'm') !== false) {
         $months = floor($rest / self::MONTH);
         if ($restChunks <= 1 && ($rest - $months * self::MONTH) / $diff > $precision) {
             $months = 0;
         } else {
             $restChunks--;
         }
         $rest = $rest - $months * self::MONTH;
     } else {
         $months = 0;
     }
     if (strpos($units, 'w') !== false) {
         $weeks = floor($rest / self::WEEK);
         if ($restChunks <= 1 && ($rest - $weeks * self::WEEK) / $diff > $precision) {
             $weeks = 0;
         } else {
             $restChunks--;
         }
         $rest = $rest - $weeks * self::WEEK;
     } else {
         $weeks = 0;
     }
     if (strpos($units, 'd') !== false) {
         $days = floor($rest / self::DAY);
         if ($restChunks <= 1 && ($rest - $days * self::DAY) / $diff > $precision) {
             $days = 0;
         } else {
             $restChunks--;
         }
         $rest = $rest - $days * self::DAY;
     } else {
         $days = 0;
     }
     if (strpos($units, 'h') !== false) {
         $hours = floor($rest / self::HOUR);
         if ($restChunks <= 1 && ($rest - $hours * self::HOUR) / $diff > $precision) {
             $hours = 0;
         } else {
             $restChunks--;
         }
         $rest = $rest - $hours * self::HOUR;
     } else {
         $hours = 0;
     }
     if (strpos($units, 'i') !== false) {
         $mins = floor($rest / self::MIN);
         if ($restChunks <= 1 && ($rest - $mins * self::MIN) / $diff > $precision) {
             $mins = 0;
         } else {
             $restChunks--;
         }
         $rest = $rest - $mins * self::MIN;
     } else {
         $mins = 0;
     }
     if (strpos($units, 's') !== false) {
         $seconds = $rest;
     } else {
         $seconds = 0;
     }
     $chunks = array('year(s)' => $years, 'month(s)' => $months, 'week(s)' => $weeks, 'day(s)' => $days, 'hour(s)' => $hours, 'min(s)' => $mins, 'second(s)' => $seconds);
     $outputStr = '';
     $i = 0;
     foreach ($chunks as $chunkName => $value) {
         if ($value) {
             if ($translator) {
                 $chunkName = $translator->translate($chunkName);
             }
             $translatedChunkNames = explode(" ", $chunkName);
             $translatedChunkName = Lms_Text::declension($value, $translatedChunkNames, $lang);
             $outputStr .= " {$value} {$translatedChunkName}";
             $i++;
             if ($i >= $limitReturnChunks) {
                 break;
             }
         }
     }
     $outputStr = trim($outputStr);
     return $outputStr;
 }
开发者ID:nagyistoce,项目名称:lanmediaservice-lms-lib,代码行数:98,代码来源:Date.php

示例14: getDesc

 /**
  * Retorna uma breve descrição de funcionamento da ação.
  * @return Descrição de funcionamento ou objetivo
  */
 public function getDesc()
 {
     return $this->i18n->translate("Dial to a Trunk");
 }
开发者ID:rootzig,项目名称:SNEP,代码行数:8,代码来源:DialTrunk.php

示例15: getNavigation

 /**
  * return navigation bar
  * @return string html                class="PageNavigation" 
  */
 public function getNavigation()
 {
     $navigation = '<div style="text-align:' . $this->_align . '">';
     $pageCote = ceil($this->_currentPage / ($this->_navigationItemCount - 1)) - 1;
     //the location cote of current page in the navigation当前页处于第几栏分页
     $pageCoteCount = ceil($this->_pageCount / ($this->_navigationItemCount - 1));
     //the total page cote
     $pageStart = $pageCote * ($this->_navigationItemCount - 1) + 1;
     //the start page in cote
     $pageEnd = $pageStart + $this->_navigationItemCount - 1;
     //the end page in cote
     if ($this->_pageCount < $pageEnd) {
         $pageEnd = $this->_pageCount;
         //the total number of page
     }
     //                $navigation .= "(In all)总共:{$this->_pageCount}(Page)页\n";
     //config Zend_Translate for Pagination.php
     $config = new Zend_Config_Ini("../application/config.ini", "dev");
     $langNamespace = new Zend_Session_Namespace('Lang');
     $translate = new Zend_Translate('tmx', strval($config->framework->language->dir), $langNamespace->lang);
     $navigation .= $translate->translate("His_Page") . ":";
     if ($pageCote > 0) {
         $navigation .= '<a href="' . $this->createHref(1) . "\">{$this->_firstPageString}</a> ";
     }
     if ($this->_currentPage != 1) {
         $navigation .= '<a href="' . $this->createHref($this->_currentPage - 1);
         $navigation .= "\">{$this->_previousPageString}</a> ";
     }
     if ($this->_currentPage == 1) {
         $navigation .= '<a href="' . $this->createHref($this->_currentPage);
         $navigation .= "\">{$this->_previousPageString}</a> ";
     }
     while ($pageStart <= $pageEnd) {
         if ($pageStart == $this->_currentPage) {
             $navigation .= "<strong>{$pageStart}</strong>" . $this->_splitString;
         } else {
             $navigation .= '<a href="' . $this->createHref($pageStart) . "\">{$pageStart}</a>" . $this->_splitString;
         }
         $pageStart++;
     }
     if ($this->_currentPage != $this->_pageCount) {
         $navigation .= ' <a href="' . $this->createHref($this->_currentPage + 1) . "\">{$this->_nextPageString}</a> ";
     }
     if ($this->_currentPage == $this->_pageCount) {
         $navigation .= ' <a href="' . $this->createHref($this->_currentPage) . "\">{$this->_nextPageString}</a> ";
     }
     if ($pageCote < $pageCoteCount - 1) {
         $navigation .= '<a href="' . $this->createHref($this->_pageCount) . "\">{$this->_lastPageString}</a> ";
     }
     //add 'direct navigation select'
     //$navigation .= '<input type="text" size="3" onkeydown="if(event.keyCode==13){window.location=\' ';
     //$navigation .= $this->createHref().'\'+this.value;return false;}" />';
     //Bug fix(2008.8.27): there is an error when we input the wrong page number  ------begin
     //        $navigation .= '  <select onchange="window.location=\' '.$this->createHref().'\'+this.options[this.selectedIndex].value;">';
     //        for ($i=1;$i<=$this->_pageCount;$i++){
     //                if ($this->getCurrentPage()==$i){
     //                        $selected = "selected";
     //                }
     //                else {
     //                        $selected = "";
     //                }
     //                $navigation .= '<option value='.$i.' '.$selected.'>'.$i.'</option>';
     //        }
     //        $navigation .= '</select>';
     //Bug fix(2008.8.27): there is an error when we input the wrong page number  ------end
     $navigation .= "</div>";
     return $navigation;
 }
开发者ID:omusico,项目名称:wildfire_php,代码行数:72,代码来源:Pagination.php


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