當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。