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


PHP i18n类代码示例

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


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

示例1: init

    public function init()
    {
        // Send default settings according to locale
        $locale = i18n::get_locale();
        $symbols = Zend_Locale_Data::getList($locale, 'symbols');
        $currency = Currency::config()->currency_symbol;
        $decimals = $symbols['decimal'];
        $thousands = $decimals == ',' ? ' ' : ',';
        // Accouting needs to be initialized globally
        FormExtraJquery::include_accounting();
        Requirements::customScript(<<<EOT
    window.accounting.settings = {
        currency: {
            symbol : "{$currency}",
            format: "%s%v",
            decimal : "{$decimals}",
            thousand: "{$thousands}",
            precision : 2
        },
        number: {
            precision : 0,
            thousand: "{$thousands}",
            decimal : "{$decimals}"
        }
    }
EOT
, 'accountingInit');
    }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:28,代码来源:FormExtraLeftAndMainExtension.php

示例2: glossar_replace

 function glossar_replace($string)
 {
     global $REX, $mypage;
     $I18N_GLOSSAR = new i18n($REX[LANG], $REX[INCLUDE_PATH] . "/addons/{$mypage}/lang/");
     // CREATE LANG OBJ FOR THIS ADDON
     $sql = new sql();
     $sql->setQuery("select * from rex__glossar order by shortcut");
     for ($i = 0; $i < $sql->getRows(); $i++) {
         $language = $sql->getValue("language");
         if ($language == "0") {
             $language = $I18N_GLOSSAR->msg('lang_de_short');
         } elseif ($language == "1") {
             $language = $I18N_GLOSSAR->msg('lang_en_short');
         } else {
             $language = $I18N_GLOSSAR->msg('lang_fr_short');
         }
         $id = $sql->getValue("short_id");
         $shortcut = htmlentities($sql->getValue("shortcut"));
         $escapedshortcut = str_replace('.', '\\.', $shortcut);
         $description = htmlentities($sql->getValue("description"));
         $language = trim($language);
         $casesense = $sql->getValue("casesense");
         $search = "/((<[^>]*)|{$escapedshortcut})/e";
         $replace = '"\\2"=="\\1"? "\\1":"<span lang=\\"' . $language . '\\" xml:lang=\\"' . $language . '\\" title=\\"' . $language . ': ' . $description . '\\" class=\\"shortcut\\">' . $shortcut . '</span>"';
         $subject = $string;
         if ($casesense == 0) {
             $search .= 'i';
         }
         $string = preg_replace($search, $replace, $subject);
         $sql->counter++;
     }
     return $string;
 }
开发者ID:BackupTheBerlios,项目名称:redaxo,代码行数:33,代码来源:config.inc.php

示例3: getList

 function getList()
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $i18n = new i18n($registry->get('i18n_path') . 'router.xml');
     $renderer = new Renderer(Page::MODE_NORMAL);
     $pTitle = $i18n->get('title');
     $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', RouterListView::get(['list' => Router::getList()]));
     $renderer->loadPage();
     $renderer->output();
 }
开发者ID:jne21,项目名称:WBT,代码行数:11,代码来源:RouterController.php

示例4: tearDown

 public function tearDown()
 {
     parent::tearDown();
     i18n::set_locale($this->originalLocale);
     Config::inst()->remove('TimeField', 'default_config');
     Config::inst()->update('TimeField', 'default_config', $this->origTimeConfig);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:7,代码来源:TimeFieldTest.php

示例5: getInstance

 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new i18n();
     }
     return self::$instance;
 }
开发者ID:BackupTheBerlios,项目名称:openpb-svn,代码行数:7,代码来源:example5.php

示例6: init

 public function init()
 {
     parent::init();
     Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
     Requirements::javascript("jsparty/tiny_mce_improvements.js");
     Requirements::javascript("jsparty/hover.js");
     Requirements::javascript("jsparty/scriptaculous/controls.js");
     Requirements::javascript("cms/javascript/SecurityAdmin.js");
     Requirements::javascript("cms/javascript/LeftAndMain_left.js");
     Requirements::javascript("cms/javascript/LeftAndMain_right.js");
     Requirements::javascript("cms/javascript/CMSMain_left.js");
     Requirements::javascript("cms/javascript/ReportAdmin_left.js");
     Requirements::javascript("cms/javascript/ReportAdmin_right.js");
     Requirements::css("cms/css/ReportAdmin.css");
     // TODO Find a better solution to integrate optional Requirements in a specific order
     if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
         Requirements::css("ecommerce/css/DataReportCMSMain.css");
     }
     if (Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
         Requirements::javascript("ecommerce/javascript/DataReport.js");
     }
     if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
         Requirements::css(project() . "/css/DataReportCMSMain.css");
     }
     if (Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
         Requirements::javascript(project() . "/javascript/DataReport.js");
     }
     // We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
     if (!Director::is_ajax()) {
         Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array("ContentCSS" => project() . "/css/editor.css", "BaseURL" => Director::absoluteBaseURL(), "Lang" => i18n::get_tinymce_lang()));
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:32,代码来源:ReportAdmin.php

示例7: Content

 public function Content()
 {
     if (i18n::get_locale() === 'zh_CN') {
         return $this->Content_cn;
     }
     return $this->Content;
 }
开发者ID:shawn3a,项目名称:ss_powermoney,代码行数:7,代码来源:AboutPage.php

示例8: 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

示例9: convertCountryCodeToName

 /**
  * Convert country code to name
  *
  * @param string $code
  * @return string
  */
 public static function convertCountryCodeToName($code)
 {
     if (!$code) {
         return;
     }
     return Zend_Locale::getTranslation($code, 'territory', i18n::get_locale());
 }
开发者ID:lekoala,项目名称:silverstripe-geotools,代码行数:13,代码来源:GeoExtension.php

示例10: init

 /**
  * Initializing i18n
  *
  * @param array $options
  */
 public static function init($options = [])
 {
     $i18n = application::get('flag.global.i18n') ?? [];
     $i18n = array_merge_hard($i18n, $options ?? []);
     // determine final language
     $languages = factory::model('numbers_backend_i18n_languages_model_languages')->get();
     $final_language = application::get('flag.global.__language_code') ?? session::get('numbers.entity.format.language_code') ?? $i18n['language_code'] ?? 'sys';
     if (empty($languages[$final_language])) {
         $final_language = 'sys';
         $i18n['rtl'] = 0;
     }
     // put settings into system
     if (!empty($languages[$final_language])) {
         foreach ($languages[$final_language] as $k => $v) {
             $k = str_replace('lc_language_', '', $k);
             if (in_array($k, ['code', 'inactive'])) {
                 continue;
             }
             if (empty($v)) {
                 continue;
             }
             $i18n[$k] = $v;
         }
     }
     $i18n['language_code'] = $final_language;
     self::$options = $i18n;
     session::set('numbers.entity.format.language_code', $final_language);
     application::set('flag.global.i18n', $i18n);
     self::$initialized = true;
     // initialize the module
     return factory::submodule('flag.global.i18n.submodule')->init($i18n);
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:37,代码来源:i18n.php

示例11: tearDown

 public function tearDown()
 {
     parent::tearDown();
     i18n::set_locale($this->originalLocale);
     DateField::$default_config['dateformat'] = $this->origDateFormat;
     TimeField::$default_config['timeformat'] = $this->origTimeFormat;
 }
开发者ID:normann,项目名称:sapphire,代码行数:7,代码来源:DatetimeFieldTest.php

示例12: run

 function run()
 {
     $id = (int) $this->get_param('id');
     $page = (int) $this->get_param('page');
     // @todo move pagination to filters?
     if (!$page) {
         $page = ($pf = $this->_controller->get_router()->get_filter('pagination')) ? $pf->get_start() : 0;
     }
     // load by id
     $searchs = $this->_controller->get_context()->get_search_handle();
     $search_results = $this->_controller->get_context()->get_search_result_handle();
     $item = $searchs->get_by_id($id);
     if ($item) {
         $this->renderer->set_return('keyword', $item->keyword);
         if ($item->c_count) {
             /** @var \tf\core\collection_filter*/
             $f = $search_results->set_order('time DESC')->get_filter('/search/' . $id . '/')->set_config(array('where_sql' => 'pid = ' . $item->id))->set_per_page($this->_per_page)->set_pagination($page);
             $this->renderer->set_return('posts', $f->apply()->as_array());
         } else {
             $this->renderer->set_message(i18n::T('sat.search_not_found'), false);
             return false;
         }
     } else {
         $this->renderer->set_return('keyword', '');
     }
 }
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:26,代码来源:result.php

示例13: Special

 public function Special()
 {
     if (i18n::get_locale() === 'zh_CN') {
         return $this->Special_cn;
     }
     return $this->Special;
 }
开发者ID:shawn3a,项目名称:ss_powermoney,代码行数:7,代码来源:PowerPlan.php

示例14: setUp

 public function setUp()
 {
     /* Setup Routine */
     $page = new RainTPL();
     $page::configure(array('cache_dir' => 'tmp/'));
     $page::$path_replace = false;
     // We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
     $page->assign('CIPHERDATA', htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES));
     $page->assign('ERROR', self::$error);
     $page->assign('STATUS', self::$status);
     $page->assign('VERSION', self::$version);
     $page->assign('DISCUSSION', true);
     $page->assign('OPENDISCUSSION', true);
     $page->assign('MARKDOWN', true);
     $page->assign('SYNTAXHIGHLIGHTING', true);
     $page->assign('SYNTAXHIGHLIGHTINGTHEME', 'sons-of-obsidian');
     $page->assign('BURNAFTERREADINGSELECTED', false);
     $page->assign('PASSWORD', true);
     $page->assign('FILEUPLOAD', false);
     $page->assign('BASE64JSVERSION', '2.1.9');
     $page->assign('NOTICE', 'example');
     $page->assign('LANGUAGESELECTION', '');
     $page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
     $page->assign('EXPIRE', self::$expire);
     $page->assign('EXPIREDEFAULT', self::$expire_default);
     $page->assign('EXPIRECLONE', true);
     ob_start();
     $page->draw('page');
     $this->_content = ob_get_contents();
     // run a second time from cache
     $page->cache('page');
     $page->draw('page');
     ob_end_clean();
 }
开发者ID:danesjenovdan,项目名称:DJNBin,代码行数:34,代码来源:RainTPL.php

示例15: CurrencySymbol

 public function CurrencySymbol()
 {
     require_once THIRDPARTY_PATH . "/Zend/Currency.php";
     $locale = new Zend_Locale(i18n::get_locale());
     $symbol = new Zend_Currency($locale);
     return $symbol->getSymbol();
 }
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:BootstrapCurrencyField.php


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