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