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


PHP sfI18N::__方法代碼示例

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


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

示例1: __

 public function __($string, $args = array(), $catalogue = 'messages')
 {
     foreach ($args as $k => $v) {
         if ($v instanceof SnsTerm) {
             $args[$k] = (string) $v;
         }
     }
     if (empty($parsed[$string])) {
         $this->parsed[$string] = array();
         $matches = array();
         preg_match_all('/%([a-zA-Z_]+)%/', $string, $matches);
         array_shift($matches);
         foreach ($matches as $match) {
             foreach ($match as $v) {
                 if ($this->terms[$v]) {
                     $term = $this->terms[$v];
                     if ($this->titleize) {
                         $term = $term->titleize();
                     }
                     $this->parsed[$string]['%' . $v . '%'] = (string) $term;
                 }
             }
         }
     }
     return parent::__($string, array_merge($this->parsed[$string], $args), $catalogue);
 }
開發者ID:Kazuhiro-Murota,項目名稱:OpenPNE3,代碼行數:26,代碼來源:opI18N.class.php

示例2: EnglishSentence

}
$t->is($i18n->__(new EnglishSentence()), 'une phrase en français', '->__() translates an object with __toString()');
$args = array('%timestamp%' => $timestamp = time());
$t->is($i18n->__('Current timestamp is %timestamp%', $args), strtr('Le timestamp courant est %timestamp%', $args), '->__() takes an array of arguments as its second argument');
$t->is($i18n->__('an english sentence', array(), 'messages_bis'), 'une phrase en français (bis)', '->__() takes a catalogue as its third argument');
// test for #2161
$t->is($i18n->__('1 minute'), '1 menit', '->__() "1 minute" translated as "1 menit"');
$t->is($i18n->__('1'), '1', '->__() "1" translated as "1"');
$t->is($i18n->__(1), '1', '->__() number 1 translated as "1"');
$i18n->setCulture('fr_BE');
$t->is($i18n->__('an english sentence'), 'une phrase en belge', '->__() translates a string');
// debug
$i18n = new sfI18N($configuration, $cache, array('debug' => true));
$t->is($i18n->__('unknown'), '[T]unknown[/T]', '->__() adds a prefix and a suffix on untranslated strings if debug is on');
$i18n = new sfI18N($configuration, $cache, array('debug' => true, 'untranslated_prefix' => '-', 'untranslated_suffix' => '#'));
$t->is($i18n->__('unknown'), '-unknown#', '->initialize() can change the default prefix and suffix dor untranslated strings');
// ->getCountry()
$t->diag('->getCountry()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getCountry('FR'), 'France', '->getCountry() returns the name of a country for the current culture');
$t->is($i18n->getCountry('FR', 'es'), 'Francia', '->getCountry() takes an optional culture as its second argument');
// ->getNativeName()
$t->diag('->getNativeName()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getNativeName('fr'), 'français', '->getNativeName() returns the name of a culture');
// ->getTimestampForCulture()
$t->diag('->getTimestampForCulture()');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->getTimestampForCulture('15/10/2005'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is($i18n->getTimestampForCulture('15/10/2005 15:33'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture');
$t->is($i18n->getTimestampForCulture('10/15/2005', 'en_US'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument');
開發者ID:mediasadc,項目名稱:alba,代碼行數:31,代碼來源:sfI18NTest.php


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