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


PHP i18n::getInstance方法代碼示例

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


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

示例1: testTranslationCaching

 function testTranslationCaching()
 {
     Configure::write('Config.language', 'cache_test_po');
     $i18n =& i18n::getInstance();
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     #$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->__domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom1['LC_MESSAGES']['dom1.foo'], 'Dom 1 Foo');
     $this->assertEqual($cachedDom1['LC_MESSAGES']['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');
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.foo'], 'Dom 2 Foo');
     $this->assertEqual($cachedDom2['LC_MESSAGES']['dom2.bar'], 'Dom 2 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->assertEqual(I18n::translate('dom1.foo', false, 'dom1'), 'FOO');
 }
開發者ID:kevinmel2000,項目名稱:Study-Buddy---CakePHP-Quiz-System,代碼行數:33,代碼來源:i18n.test.php

示例2: dirname

<?php

require_once dirname(__FILE__) . '/inc/lib.inc';
require_once dirname(__FILE__) . '/inc/meta.inc';
require_once dirname(__FILE__) . '/inc/i18n.inc';
require_once dirname(__FILE__) . '/inc/config.inc';
require_once dirname(__FILE__) . '/inc/Mustache.php';
$i18n = i18n::getInstance();
$config = Config::getInstance();
$do = $_GET['do'];
if (!$do) {
    $do = $_POST['do'];
}
if (!$do) {
    $do = 'home';
}
$lang = $_GET['lg'];
if (!$lang) {
    $lang = $_POST['lg'];
}
if (!$lang) {
    $lang = 'pt';
}
global $default_collection, $default_collection_id;
$query = $_GET['q'];
$tag = preg_replace('/\\\\"/', '"', $_POST['t']);
$limit = intval($_GET['limit']);
if (!$limit) {
    $limit = 10;
}
$offset = intval($_GET['offset']);
開發者ID:NunoCardoso,項目名稱:Rembrandt,代碼行數:31,代碼來源:index.php

示例3: parseUserSettings

 protected function parseUserSettings(array $args)
 {
     if (!empty($args)) {
         foreach ($args as $param => $value) {
             if ($param === 'lang') {
                 $langs = $this->registry->get('languages:langs', array('en' => 'English'), 'docbook');
                 /*
                 echo '<br />';
                 var_export($value);
                 var_export($langs);
                 */
                 if (array_key_exists($value, $langs)) {
                     i18n::getInstance()->setLanguage($value);
                     $true_language = i18n::getInstance()->getLanguage();
                     //var_export($true_language);
                     if (!isset($_SESSION['lang']) || $_SESSION['lang'] !== $true_language) {
                         $_SESSION['lang'] = $true_language;
                     }
                 }
             }
         }
     }
     //var_export($args);
     //exit('yo');
 }
開發者ID:atelierspierrot,項目名稱:docbook,代碼行數:25,代碼來源:FrontController.php


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