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


PHP i18n::translate方法代码示例

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


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

示例1: testTranslationCaching

 function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     $i18n =& i18n::getInstance();
     // reset cache & i18n
     $i18n->__destruct();
     Cache::clear(false, '_cake_core_');
     $lang = $i18n->l10n->locale;
     Cache::config('_cake_core_', Cache::config('default'));
     // make some calls to translate using different domains
     $this->assertEqual(i18n::translate('dom1.foo', false, 'dom1'), 'Dom 1 Foo');
     $this->assertEqual(i18n::translate('dom1.bar', false, 'dom1'), 'Dom 1 Bar');
     $this->assertEqual($i18n->__cache[0]['key'], 'dom1_' . $lang);
     $this->assertEqual($i18n->__cache[0]['domain'], 'dom1');
     $this->assertEqual($i18n->__domains['LC_MESSAGES']['cache_test_po']['dom1']['dom1.foo'], 'Dom 1 Foo');
     // destruct -> writes to cache
     $i18n->__destruct();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom1['dom1.foo'], 'Dom 1 Foo');
     $this->assertEqual($cachedDom1['dom1.bar'], 'Dom 1 Bar');
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEqual(i18n::translate('dom2.foo', false, 'dom2'), 'Dom 2 Foo');
     // modify cache entry to verify that dom1 entry is now read from cache
     $cachedDom1['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEqual(i18n::translate('dom1.foo', false, 'dom1'), 'FOO');
     // verify that only dom2 will be cached now
     $this->assertEqual($i18n->__cache[0]['key'], 'dom2_' . $lang);
     $this->assertEqual(count($i18n->__cache), 1);
     // write to cache
     $i18n->__destruct();
     // verify caching through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom2['dom2.foo'], 'Dom 2 Foo');
     $this->assertEqual($cachedDom2['dom2.bar'], 'Dom 2 Bar');
 }
开发者ID:joebeeson,项目名称:cakephp,代码行数:39,代码来源:i18n.test.php

示例2: testPrefixTranslation

 public function testPrefixTranslation()
 {
     $this->assertEqual(i18n::translate('app', null, null, 'url'), 'application');
     $this->assertEqual(i18n::translate('application', null, true, 'url'), 'app');
 }
开发者ID:nicolasmartin,项目名称:framework,代码行数:5,代码来源:core.i18n.php

示例3: _getDate

 private function _getDate($format = "numeric")
 {
     if ($format == "numeric") {
         $this->_date = str_replace("%/%", $this->_dateSeparator, $this->_date);
         $this->_date = str_replace("dd", $this->_day, $this->_date);
         $this->_date = str_replace("mm", $this->_month, $this->_date);
         $this->_date = str_replace("yyyy", $this->_year, $this->_date);
         return $this->_date;
     }
     if ($format == "text") {
         $this->_dateFormat = $this->_config->getParam("namedDateFormat");
         $dayName = i18n::translate(date("l"));
         $monthName = i18n::translate(date("F"));
         $this->_date = $this->_dateFormat;
         $this->_date = str_replace("dd", date("d"), $this->_date);
         $this->_date = str_replace("Dname", $dayName, $this->_date);
         $this->_date = str_replace("Mname", $monthName, $this->_date);
         $this->_date = str_replace("yyyy", date("Y"), $this->_date);
         return $this->_date;
     }
 }
开发者ID:andreums,项目名称:framework1.5,代码行数:21,代码来源:timeHelper.php

示例4: __

/**
 * A wrapper for i18n::translate();
 *
 * You can use it as if it has 2 arguments and then pass the rest of the arguments as arguments to go to sprintf.
 */
function __($section, $key = null, $locale = 'DEFAULT')
{
    if (func_num_args() > 3 || func_num_args() > 2 && $locale !== 'DEFAULT') {
        $args = func_get_args();
        return call_user_func_array('i18n::translate', $args);
    }
    return i18n::translate($section, $key, $locale);
}
开发者ID:alecgorge,项目名称:TopHat,代码行数:13,代码来源:cc-i18n.php


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