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


PHP Locale::setDefault方法代碼示例

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


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

示例1: testValidateUsingCountrySpecificLocale

 public function testValidateUsingCountrySpecificLocale()
 {
     \Locale::setDefault('en_GB');
     $existingCountry = 'GB';
     $this->context->expects($this->never())->method('addViolation');
     $this->validator->validate($existingCountry, new Country());
 }
開發者ID:TuxCoffeeCorner,項目名稱:tcc,代碼行數:7,代碼來源:CountryValidatorTest.php

示例2: setLocale

 public function setLocale($locale)
 {
     setlocale(LC_ALL, $locale);
     setlocale(LC_TIME, $locale);
     PhpLocale::setDefault($locale);
     $this->lang->setLangId(explode('_', $locale)[0]);
 }
開發者ID:pckg,項目名稱:manager,代碼行數:7,代碼來源:Locale.php

示例3: testValidateUsingCountrySpecificLocale

 public function testValidateUsingCountrySpecificLocale()
 {
     \Locale::setDefault('fr_FR');
     $existingLanguage = 'en';
     $this->context->expects($this->never())->method('addViolation');
     $this->validator->validate($existingLanguage, new Language(array('message' => 'aMessage')));
 }
開發者ID:dev-lav,項目名稱:htdocs,代碼行數:7,代碼來源:LanguageValidatorTest.php

示例4: requireIntl

 /**
  * Should be called before tests that work fine with the stub implementation.
  */
 public static function requireIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
 {
     if (null === $minimumIcuVersion) {
         $minimumIcuVersion = Intl::getIcuStubVersion();
     }
     // We only run tests if the version is *one specific version*.
     // This condition is satisfied if
     //
     //   * the intl extension is loaded with version Intl::getIcuStubVersion()
     //   * the intl extension is not loaded
     if (($minimumIcuVersion || defined('HHVM_VERSION_ID')) && IcuVersion::compare(Intl::getIcuVersion(), $minimumIcuVersion, '!=', 1)) {
         $testCase->markTestSkipped('ICU version ' . $minimumIcuVersion . ' is required.');
     }
     // Normalize the default locale in case this is not done explicitly
     // in the test
     \Locale::setDefault('en');
     // Consequently, tests will
     //
     //   * run only for one ICU version (see Intl::getIcuStubVersion())
     //     there is no need to add control structures to your tests that
     //     change the test depending on the ICU version.
     //
     // Tests should only rely on functionality that is implemented in the
     // stub classes.
 }
開發者ID:yceruto,項目名稱:symfony,代碼行數:28,代碼來源:IntlTestHelper.php

示例5: setupDependencyInjection

 /**
  * Append objects to the global dependency injection container.
  *
  * @param Pimple\Container $container
  */
 public static function setupDependencyInjection(Container $container)
 {
     parent::setupDependencyInjection($container);
     $locale = $container['session']->get('_locale', 'en');
     $container['request']->setLocale($locale);
     \Locale::setDefault($locale);
 }
開發者ID:QuangDang212,項目名稱:roadiz,代碼行數:12,代碼來源:InstallApp.php

示例6: testConstructor

 public function testConstructor()
 {
     // Testing defaults
     $validator = new CurrencyValidator();
     $this->assertEquals('en_US', $validator->getLocale());
     $this->assertEquals(Uncurrency::DEFAULT_SCALE_CORRECTNESS, $validator->getScaleCorrectness());
     $this->assertEquals(Uncurrency::DEFAULT_CURRENCY_CORRECTNESS, $validator->getCurrencyCorrectness());
     $this->assertEquals(CurrencyValidator::DEFAULT_NEGATIVE_ALLOWED, $validator->isNegativeAllowed());
     // Testing application locale
     \Locale::setDefault('de_DE');
     $validator = new CurrencyValidator();
     $this->assertEquals('de_DE', $validator->getLocale());
     // Testing locale
     $validator = new CurrencyValidator(['locale' => 'it_IT']);
     $this->assertEquals('it_IT', $validator->getLocale());
     // Testing options
     $validator = new CurrencyValidator(['locale' => 'it_IT', 'currency_code' => 'EUR', 'scale_correctness' => false, 'currency_correctness' => false, 'negative_allowed' => false]);
     $this->assertFalse($validator->getScaleCorrectness());
     $this->assertFalse($validator->getCurrencyCorrectness());
     $this->assertFalse($validator->isNegativeAllowed());
     // Testing traversable
     $traversableOpts = new ArrayObject(['locale' => 'it_IT', 'currency_code' => 'EUR', 'scale_correctness' => true, 'currency_correctness' => false, 'negative_allowed' => true]);
     $validator = new CurrencyValidator();
     $validator->setOptions($traversableOpts);
     $this->assertEquals('it_IT', $validator->getLocale());
     $this->assertTrue($validator->getScaleCorrectness());
     $this->assertFalse($validator->getCurrencyCorrectness());
     $this->assertTrue($validator->isNegativeAllowed());
 }
開發者ID:leodido,項目名稱:moneylaundry,代碼行數:29,代碼來源:CurrencyTest.php

示例7: onBootstrap

 /**
  * @param MvcEvent $event
  */
 public function onBootstrap(MvcEvent $event)
 {
     $eventManager = $event->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $application = $event->getApplication();
     $eventManager = $application->getEventManager();
     /* @var $serviceManager ServiceManager */
     $serviceManager = $application->getServiceManager();
     $config = $serviceManager->get('config');
     if (array_key_exists('locale', $config)) {
         $config = $config['locale'];
     } else {
         $config = null;
     }
     if (!$config) {
         Locale::setDefault('en');
         // hardcoded here
         $translator = $serviceManager->get('translator');
         AbstractValidator::setDefaultTranslator($translator);
         return;
     }
     $settings = new Settings($config);
     // set the locale based on URL from route or cookie & set the default translator to all the app
     $eventManager->attach(MvcEvent::EVENT_ROUTE, function (MvcEvent $e) use($config, $settings, $serviceManager) {
         $settings->setRouteMatch($e->getRouteMatch());
         if (!$e->getRequest() instanceof Request) {
             $settings->setRequest($e->getRequest());
         }
         \Locale::setDefault($settings->getLocale());
         $translator = $serviceManager->get('translator');
         AbstractValidator::setDefaultTranslator($translator);
     }, -9);
 }
開發者ID:middleout,項目名稱:mdo-bundle-zf2-locale,代碼行數:37,代碼來源:Module.php

示例8: testOverrideCurrency

 public function testOverrideCurrency()
 {
     \Locale::setDefault("fr_FR");
     $form = $this->factory->create($this->simpleMoneyTypeClass, null, ["currency" => "USD"]);
     $form->submit(array("tbbc_amount" => '1 252,5'));
     $this->assertEquals(Money::USD(125250), $form->getData());
 }
開發者ID:BboyKeen,項目名稱:TbbcMoneyBundle,代碼行數:7,代碼來源:SimpleMoneyTypeTest.php

示例9: testDefaultLocaleFromHttpHeader

 public function testDefaultLocaleFromHttpHeader()
 {
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'sv-se,sv;q=0.8,en-us;q=0.6,en;q=0.4';
     \Locale::setDefault('fi');
     \Library\Application::init('Console', true);
     $this->assertEquals('sv_SE', \Locale::getDefault());
 }
開發者ID:hschletz,項目名稱:braintacle,代碼行數:7,代碼來源:LocalizationTest.php

示例10: tearDown

 protected function tearDown()
 {
     parent::tearDown();
     \Locale::setDefault($this->locale);
     unset($this->locale);
     unset($this->formType);
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:7,代碼來源:OroPercentTypeTest.php

示例11: requireFullIntl

 /**
  * Should be called before tests that require a feature-complete intl
  * implementation.
  *
  * @param \PhpUnit_Framework_TestCase $testCase
  */
 public static function requireFullIntl(\PhpUnit_Framework_TestCase $testCase)
 {
     // We only run tests if the intl extension is loaded...
     if (!Intl::isExtensionLoaded()) {
         $testCase->markTestSkipped('The intl extension is not available.');
     }
     // ... and only if the version is *one specific version* ...
     if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) {
         $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion());
     }
     // ... and only if the data in the Icu component matches that version.
     if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', $precision = 1)) {
         $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x');
     }
     // Normalize the default locale in case this is not done explicitly
     // in the test
     \Locale::setDefault('en');
     // Consequently, tests will
     //
     //   * run only for one ICU version (see Intl::getIcuStubVersion())
     //     there is no need to add control structures to your tests that
     //     change the test depending on the ICU version.
     //   * always use the C intl classes
     //   * always use the binary resource bundles (any locale is allowed)
 }
開發者ID:bonett23,項目名稱:pruebaTweetsSymfony2Hely,代碼行數:31,代碼來源:IntlTestHelper.php

示例12: setUp

 protected function setUp()
 {
     \Locale::setDefault('en');
     $dispatcher = new EventDispatcher();
     $this->csrfProvider = $this->getMock('Symfony\\Component\\Form\\Extension\\Csrf\\CsrfProvider\\CsrfProviderInterface');
     $this->factory = new FormFactory(array(new CoreExtension(), new CsrfExtension($this->csrfProvider)));
 }
開發者ID:NicolasBadey,項目名稱:symfony,代碼行數:7,代碼來源:AbstractLayoutTest.php

示例13: testValidCurrenciesWithCountrySpecificLocale

 /**
  * @dataProvider getValidCurrencies
  **/
 public function testValidCurrenciesWithCountrySpecificLocale($currency)
 {
     IntlTestHelper::requireFullIntl($this);
     \Locale::setDefault('en_GB');
     $this->validator->validate($currency, new Currency());
     $this->assertNoViolation();
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:10,代碼來源:CurrencyValidatorTest.php

示例14: testToString

 public function testToString($value, $currencyCode, $expectedOutput)
 {
     if (Intl::isExtensionLoaded()) {
         \Locale::setDefault('en');
     }
     $this->if($price = new TestedPrice($value, $currencyCode))->phpString((string) $price)->isIdenticalTo($expectedOutput);
 }
開發者ID:rezzza,項目名稱:accounting,代碼行數:7,代碼來源:Price.php

示例15: testMoneyPatternWorksForYen

 public function testMoneyPatternWorksForYen()
 {
     \Locale::setDefault('en_US');
     $form = $this->factory->create('money', null, array('currency' => 'JPY'));
     $view = $form->createView();
     $this->assertTrue((bool) strstr($view->get('money_pattern'), '¥'));
 }
開發者ID:nicodmf,項目名稱:symfony,代碼行數:7,代碼來源:MoneyTypeTest.php


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