當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Translation::init方法代碼示例

本文整理匯總了PHP中Translation::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translation::init方法的具體用法?PHP Translation::init怎麽用?PHP Translation::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Translation的用法示例。


在下文中一共展示了Translation::init方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: 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

示例3: testInit

 /**
  * Test
  *
  * @return void
  */
 public function testInit()
 {
     $this->assertNull($this->object->init());
 }
開發者ID:gotcms,項目名稱:gotcms,代碼行數:9,代碼來源:TranslationTest.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

示例5: localize

/**
 * Localize a text to the locale/culture specified in the globalization handler.
 * @param string text to be localized.
 * @param array a set of parameters to substitute.
 * @param string a different catalogue to find the localize text.
 * @param string the input AND output charset.
 * @return string localized text. 
 * @see TTranslate::formatter()
 * @see TTranslate::init()
 */
function localize($text, $parameters = array(), $catalogue = null, $charset = null)
{
    $app = pradoGetApplication()->getGlobalization();
    $params = array();
    foreach ($parameters as $key => $value) {
        $params['{' . $key . '}'] = $value;
    }
    //no translation handler provided
    if (empty($app->Translation)) {
        return strtr($text, $params);
    }
    Translation::init();
    if (empty($catalogue) && isset($app->Translation['catalogue'])) {
        $catalogue = $app->Translation['catalogue'];
    }
    //globalization charset
    $appCharset = is_null($app) ? '' : $app->Charset;
    //default charset
    $defaultCharset = is_null($app) ? 'UTF-8' : $app->getDefaultCharset();
    //fall back
    if (empty($charset)) {
        $charset = $appCharset;
    }
    if (empty($charset)) {
        $charset = $defaultCharset;
    }
    return Translation::formatter()->format($text, $params, $catalogue, $charset);
}
開發者ID:joybinchen,項目名稱:svnmanager-1.09,代碼行數:38,代碼來源:Translation.php

示例6: localize

/**
 * Localize a text to the locale/culture specified in the globalization handler.
 * @param string text to be localized.
 * @param array a set of parameters to substitute.
 * @param string a different catalogue to find the localize text.
 * @param string the output charset.
 * @return string localized text. 
 * @see TTranslate::formatter()
 * @see TTranslate::init()
 */
function localize($text, $parameters = array(), $catalogue = null, $charset = null)
{
    $app = pradoGetApplication()->getGlobalization();
    $params = array();
    foreach ($parameters as $key => $value) {
        $params['{' . $key . '}'] = $value;
    }
    //no translation handler provided
    if (empty($app->Translation)) {
        return strtr($text, $params);
    }
    Translation::init();
    if (empty($catalogue) && isset($app->Translation['catalogue'])) {
        $catalogue = $app->Translation['catalogue'];
    }
    return Translation::formatter()->format($text, $params, $catalogue, $charset);
}
開發者ID:BackupTheBerlios,項目名稱:php5cms-svn,代碼行數:27,代碼來源:Translation.php


注:本文中的Translation::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。