本文整理汇总了PHP中i18n类的典型用法代码示例。如果您正苦于以下问题:PHP i18n类的具体用法?PHP i18n怎么用?PHP i18n使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了i18n类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testLinks
public function testLinks()
{
// Run link checker
$task = CheckExternalLinksTask::create();
$task->setSilent(true);
// Be quiet during the test!
$task->runLinksCheck();
// Get all links checked
$status = BrokenExternalPageTrackStatus::get_latest();
$this->assertEquals('Completed', $status->Status);
$this->assertEquals(5, $status->TotalPages);
$this->assertEquals(5, $status->CompletedPages);
// Check all pages have had the correct HTML adjusted
for ($i = 1; $i <= 5; $i++) {
$page = $this->objFromFixture('ExternalLinksTest_Page', 'page' . $i);
$this->assertNotEmpty($page->Content);
$this->assertEquals($page->ExpectedContent, $page->Content, "Assert that the content of page{$i} has been updated");
}
// Check that the correct report of broken links is generated
$links = $status->BrokenLinks()->sort('Link');
$this->assertEquals(4, $links->count());
$this->assertEquals(array('http://www.broken.com', 'http://www.broken.com/url/thing', 'http://www.broken.com/url/thing', 'http://www.nodomain.com'), array_values($links->map('ID', 'Link')->toArray()));
// Check response codes are correct
$expected = array('http://www.broken.com' => 403, 'http://www.broken.com/url/thing' => 404, 'http://www.nodomain.com' => 0);
$actual = $links->map('Link', 'HTTPCode')->toArray();
$this->assertEquals($expected, $actual);
// Check response descriptions are correct
i18n::set_locale('en_NZ');
$expected = array('http://www.broken.com' => '403 (Forbidden)', 'http://www.broken.com/url/thing' => '404 (Not Found)', 'http://www.nodomain.com' => '0 (Server Not Available)');
$actual = $links->map('Link', 'HTTPCodeDescription')->toArray();
$this->assertEquals($expected, $actual);
}
开发者ID:helpfulrobot,项目名称:govtnz-silverstripe-externallinks,代码行数:32,代码来源:ExternalLinksTest.php
示例17: locale
/**
* Get the locale of the Member, or if we're not logged in or don't have a locale, use the default one
* @return string
*/
protected function locale()
{
if (($member = Member::currentUser()) && $member->Locale) {
return $member->Locale;
}
return i18n::get_locale();
}
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:11,代码来源:CountryDropdownField.php
示例18: action_get
public function action_get()
{
try {
if (is_numeric($id_ad = $this->request->param('id'))) {
$ad = new Model_Ad($id_ad);
if ($ad->loaded()) {
if ($ad->id_user == $this->user->id_user) {
$a = $ad->as_array();
$a['price'] = i18n::money_format($ad->price);
$a['images'] = array_values($ad->get_images());
$a['category'] = $ad->category->as_array();
$a['location'] = $ad->location->as_array();
$a['customfields'] = Model_Field::get_by_category($ad->id_category);
$this->rest_output(array('ad' => $a));
} else {
$this->_error(__('Not your advertisement'), 401);
}
} else {
$this->_error(__('Advertisement not found'), 404);
}
} else {
$this->_error(__('Advertisement not found'), 404);
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
return;
}
}
开发者ID:AndresGrams,项目名称:openclassifieds2,代码行数:28,代码来源:ads.php
示例19: smarty_modifier_i18n
/**
* I18N string
*
* {"cars2\\body_type_id"|i18n}
* {"Параметр"|i18n:'module.prefix':params}
*
* Type: modifier<br>
* Name: lower<br>
* Purpose: convert string to lowercase
*
* @param string
* @return string
*/
function smarty_modifier_i18n($id, $prefix = '', $params = null)
{
if ($prefix) {
$id = $prefix . '.' . $id;
}
return i18n::T($id, $params);
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:20,代码来源:modifier.i18n.php
示例20: action_system
function action_system()
{
$this->collection->toggle_system($this->params->id, 'true' == functions::request_var('to', 'false'));
if ($this->in_ajax()) {
$this->_ajax_answer(true, i18n::T('Status changed'));
}
}
开发者ID:egregor-dev,项目名称:SatCMS,代码行数:7,代码来源:config.php
注:本文中的i18n类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论