当前位置: 首页>>代码示例>>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;未经允许,请勿转载。