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


PHP I18n::clear方法代码示例

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


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

示例1: testTranslationCaching

 /**
  * testTranslationCaching method
  *
  * @return void
  */
 public function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     Cache::config('_cake_core_', Cache::config('default'));
     // make some calls to translate using different domains
     $this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
     $this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
     $domains = I18n::domains();
     $this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
     $this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
     $this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
     // modify cache entry manually to verify that dom1 entries now will be read from cache
     $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
 }
开发者ID:kuradakis,项目名称:cakephp-ex,代码行数:37,代码来源:I18nTest.php

示例2: tearDown

 public function tearDown()
 {
     parent::tearDown();
     foreach (Configure::configured() as $config) {
         if (strpos($config, 'I18nYamlTestConfig') !== false) {
             Configure::drop($config);
         }
     }
     I18n::clear();
     App::build();
     foreach (array_keys(Configure::read()) as $key) {
         Configure::delete($key);
     }
     Configure::write($this->_config);
 }
开发者ID:hiromi2424,项目名称:yaml_reader,代码行数:15,代码来源:I18nYamlReaderTest.php

示例3: testPluginTranslationPreferApp

 /**
  * Test that Configure::read('I18n.preferApp') will prefer app.
  *
  * @return void
  */
 public function testPluginTranslationPreferApp()
 {
     // Reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     Configure::write('I18n.preferApp', true);
     App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)));
     Configure::write('Config.language', 'po');
     $singular = $this->_domainSingular();
     $this->assertEquals('Plural Rule 1', $singular);
     $plurals = $this->_domainPlural();
     $this->assertTrue(in_array('0 = 0 or > 1', $plurals));
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:18,代码来源:I18nTest.php


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