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


PHP Translation::formatter方法代码示例

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


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

示例1: init

 /**
  * Initialize the TTranslate translation components
  */
 public static function init()
 {
     //initialized the default class wide formatter
     if (is_null(self::$formatter)) {
         $app = pradoGetApplication()->getGlobalization();
         //var_dump($app);
         $source = MessageSource::factory($app->Translation['type'], $app->Translation['source'], $app->Translation['filename']);
         $source->setCulture($app->Culture);
         if ($app->Cache) {
             $source->setCache(new MessageCache($app->Cache));
         }
         self::$formatter = new MessageFormat($source, $app->Charset);
     }
 }
开发者ID:joybinchen,项目名称:svnmanager-1.09,代码行数:17,代码来源:Translation.php

示例2: localize

 public static function localize($text, $parameters = array(), $catalogue = null, $charset = null)
 {
     Prado::using('System.I18N.Translation');
     $app = Prado::getApplication()->getGlobalization(false);
     $params = array();
     foreach ($parameters as $key => $value) {
         $params['{' . $key . '}'] = $value;
     }
     if ($app === null || ($config = $app->getTranslationConfiguration()) === null) {
         return strtr($text, $params);
     }
     if ($catalogue === null) {
         $catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages';
     }
     Translation::init($catalogue);
     $appCharset = $app === null ? '' : $app->getCharset();
     $defaultCharset = $app === null ? 'UTF-8' : $app->getDefaultCharset();
     if (empty($charset)) {
         $charset = $appCharset;
     }
     if (empty($charset)) {
         $charset = $defaultCharset;
     }
     return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:25,代码来源:pradolite.php

示例3: translateText

 /**
  * Translates the text with subsititution.
  * @param string text for translation
  * @param array list of substitutions
  * @return string translated text
  */
 protected function translateText($text, $subs)
 {
     $app = $this->getApplication()->getGlobalization();
     //no translation handler provided
     if (($config = $app->getTranslationConfiguration()) === null) {
         return strtr($text, $subs);
     }
     $catalogue = $this->getCatalogue();
     if (empty($catalogue) && isset($config['catalogue'])) {
         $catalogue = $config['catalogue'];
     }
     if (empty($catalogue)) {
         $catalogue = 'messages';
     }
     Translation::init($catalogue);
     $key = $this->getKey();
     if (!empty($key)) {
         $text = $key;
     }
     //translate it
     return Translation::formatter($catalogue)->format($text, $subs, $catalogue, $this->getCharset());
 }
开发者ID:jetbill,项目名称:hospital-universitario,代码行数:28,代码来源:TTranslate.php

示例4: renderBody

 /**
  * Display the translated string.
  */
 protected function renderBody()
 {
     $app = $this->Application->getGlobalization();
     //get the text from either Property Text or the body
     $text = $this->getText();
     if (strlen($text) == 0) {
         $text = parent::renderBody();
     }
     //trim it
     if ($this->doTrim()) {
         $text = trim($text);
     }
     //no translation handler provided
     if (empty($app->Translation)) {
         return strtr($text, $this->getParameters());
     }
     Translation::init();
     $catalogue = $this->getCatalogue();
     if (empty($catalogue) && isset($app->Translation['catalogue'])) {
         $catalogue = $app->Translation['catalogue'];
     }
     $key = $this->getKey();
     if (!empty($key)) {
         $text = $key;
     }
     $charset = $this->getCharset();
     if (empty($charset)) {
         $charset = 'UTF-8';
     }
     //translate it
     return Translation::formatter()->format($text, $this->getParameters(), $catalogue, $charset);
 }
开发者ID:BackupTheBerlios,项目名称:php5cms-svn,代码行数:35,代码来源:TTranslate.php


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