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


PHP i18n::set_default_locale方法代码示例

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


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

示例1: onBeforeInit

 /**
  * We register the common forms for SilvercartPages here.
  *
  * @return void
  *
  * @author Sebastian Diel <sdiel@pixeltricks.de>,
  *         Sascha Koehler <skoehler@pixeltricks.de>,
  *         Patrick Schneider <pschneider@pixeltricks.de>
  * @since 08.07.2014
  */
 public function onBeforeInit()
 {
     SilvercartTools::initSession();
     i18n::set_default_locale(Translatable::get_current_locale());
     i18n::set_locale(Translatable::get_current_locale());
     $controllerParams = Controller::curr()->getURLParams();
     $anonymousCustomer = SilvercartCustomer::currentAnonymousCustomer();
     if ($anonymousCustomer) {
         Session::set('MemberLoginForm.force_message', true);
         if ($controllerParams['Action'] == 'changepassword') {
             $anonymousCustomer->logOut();
         }
     } else {
         Session::set('MemberLoginForm.force_message', false);
         // used to redirect the logged in user to my-account page
         $backURL = SilvercartTools::PageByIdentifierCodeLink(self::$newPasswordBackURLIdentifierCode);
         $this->owner->extend('updateNewPasswordBackURL', $backURL);
         Session::set('BackURL', $backURL);
         Session::save();
     }
     $this->owner->registerCustomHtmlForm('SilvercartQuickSearchForm', new SilvercartQuickSearchForm($this->owner));
     $this->owner->registerCustomHtmlForm('SilvercartQuickLoginForm', new SilvercartQuickLoginForm($this->owner));
     SilvercartPlugin::call($this->owner, 'init', array($this->owner));
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:34,代码来源:SilvercartSecurityController.php

示例2: __destruct

 public function __destruct()
 {
     i18n::set_default_locale($this->local);
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:4,代码来源:MemberTest.php

示例3: testCollectFromFilesystemAndWriteMasterTables

 function testCollectFromFilesystemAndWriteMasterTables()
 {
     $defaultlocal = i18n::default_locale();
     $local = i18n::get_locale();
     i18n::set_locale('en_US');
     //set the locale to the US locale expected in the asserts
     i18n::set_default_locale('en_US');
     $c = new i18nTextCollector();
     $c->basePath = $this->alternateBasePath;
     $c->baseSavePath = $this->alternateBaseSavePath;
     $c->run();
     // i18ntestmodule
     $moduleLangFile = "{$this->alternateBaseSavePath}/i18ntestmodule/lang/" . $c->getDefaultLocale() . '.php';
     $this->assertTrue(file_exists($moduleLangFile), 'Master language file can be written to modules /lang folder');
     $moduleLangFileContent = file_get_contents($moduleLangFile);
     $this->assertContains("\$lang['en_US']['i18nTestModule']['ADDITION'] = 'Addition';", $moduleLangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestModule']['ENTITY'] = array(\n\t'Entity with \"Double Quotes\"',\n\tPR_LOW,\n\t'Comment for entity'\n);", $moduleLangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestModule']['MAINTEMPLATE'] = 'Main Template';", $moduleLangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestModule']['OTHERENTITY'] = 'Other Entity';", $moduleLangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestModule']['WITHNAMESPACE'] = 'Include Entity with Namespace';", $moduleLangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestModuleInclude.ss']['NONAMESPACE'] = 'Include Entity without Namespace';", $moduleLangFileContent);
     // i18nothermodule
     $otherModuleLangFile = "{$this->alternateBaseSavePath}/i18nothermodule/lang/" . $c->getDefaultLocale() . '.php';
     $this->assertTrue(file_exists($otherModuleLangFile), 'Master language file can be written to modules /lang folder');
     $otherModuleLangFileContent = file_get_contents($otherModuleLangFile);
     $this->assertContains("\$lang['en_US']['i18nOtherModule']['ENTITY'] = 'Other Module Entity';", $otherModuleLangFileContent);
     $this->assertContains("\$lang['en_US']['i18nOtherModule']['MAINTEMPLATE'] = 'Main Template Other Module';", $otherModuleLangFileContent);
     // testtheme1
     $theme1LangFile = "{$this->alternateBaseSavePath}/themes/testtheme1/lang/" . $c->getDefaultLocale() . '.php';
     $this->assertTrue(file_exists($theme1LangFile), 'Master theme language file can be written to themes/testtheme1 /lang folder');
     $theme1LangFileContent = file_get_contents($theme1LangFile);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1']['MAINTEMPLATE'] = 'Theme1 Main Template';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1']['LAYOUTTEMPLATE'] = 'Theme1 Layout Template';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1']['SPRINTFNAMESPACE'] = 'Theme1 My replacement: %s';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1.ss']['LAYOUTTEMPLATENONAMESPACE'] = 'Theme1 Layout Template no namespace';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1.ss']['SPRINTFNONAMESPACE'] = 'Theme1 My replacement no namespace: %s';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1Include']['SPRINTFINCLUDENAMESPACE'] = 'Theme1 My include replacement: %s';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1Include']['WITHNAMESPACE'] = 'Theme1 Include Entity with Namespace';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1Include.ss']['NONAMESPACE'] = 'Theme1 Include Entity without Namespace';", $theme1LangFileContent);
     $this->assertContains("\$lang['en_US']['i18nTestTheme1Include.ss']['SPRINTFINCLUDENONAMESPACE'] = 'Theme1 My include replacement no namespace: %s';", $theme1LangFileContent);
     // testtheme2
     $theme2LangFile = "{$this->alternateBaseSavePath}/themes/testtheme2/lang/" . $c->getDefaultLocale() . '.php';
     $this->assertTrue(file_exists($theme2LangFile), 'Master theme language file can be written to themes/testtheme2 /lang folder');
     $theme2LangFileContent = file_get_contents($theme2LangFile);
     $this->assertContains("\$lang['en_US']['i18nTestTheme2']['MAINTEMPLATE'] = 'Theme2 Main Template';", $theme2LangFileContent);
     i18n::set_locale($local);
     //set the locale to the US locale expected in the asserts
     +i18n::set_default_locale($defaultlocal);
 }
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:49,代码来源:i18nTextCollectorTest.php

示例4: __construct

 /**
  * Creates a SilvercartPage_Controller
  *
  * @param array $dataRecord Data record
  * 
  * @return void
  *
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 21.02.2013
  */
 public function __construct($dataRecord = null)
 {
     i18n::set_default_locale(Translatable::get_current_locale());
     i18n::set_locale(Translatable::get_current_locale());
     parent::__construct($dataRecord);
     $this->registerWidgetSet('WidgetSetContent', $this->WidgetSetContent());
     $this->registerWidgetSet('WidgetSetSidebar', $this->WidgetSetSidebar());
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:18,代码来源:SilvercartPage.php


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