本文整理汇总了PHP中Symfony\Component\Intl\Intl::isExtensionLoaded方法的典型用法代码示例。如果您正苦于以下问题:PHP Intl::isExtensionLoaded方法的具体用法?PHP Intl::isExtensionLoaded怎么用?PHP Intl::isExtensionLoaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Intl\Intl
的用法示例。
在下文中一共展示了Intl::isExtensionLoaded方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToString
public function testToString($value, $currencyCode, $expectedOutput)
{
if (Intl::isExtensionLoaded()) {
\Locale::setDefault('en');
}
$this->if($price = new TestedPrice($value, $currencyCode))->string((string) $price)->isIdenticalTo($expectedOutput);
}
示例2: 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)
}
示例3: load
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$countryRepository = $this->getCountryRepository();
$countries = Intl::getRegionBundle()->getCountryNames($this->defaultLocale);
if (Intl::isExtensionLoaded()) {
$localisedCountries = array('es_ES' => Intl::getRegionBundle()->getCountryNames('es_ES'));
} else {
$localisedCountries = array();
}
foreach ($countries as $isoName => $name) {
$country = $countryRepository->createNew();
$country->setCurrentLocale($this->defaultLocale);
$country->setName($name);
foreach ($localisedCountries as $locale => $translatedCountries) {
$country->setCurrentLocale($locale);
$country->setName($translatedCountries[$isoName]);
}
$country->setIsoName($isoName);
if ('US' === $isoName) {
$this->addUsStates($country);
}
$manager->persist($country);
$this->setReference('Sylius.Country.' . $isoName, $country);
}
$manager->flush();
}
示例4: setUp
protected function setUp()
{
// We only run tests if the intl extension is loaded...
if (!Intl::isExtensionLoaded()) {
$this->markTestSkipped('The intl extension is not available.');
}
$this->reader = new IntlBundleReader();
}
示例5: setUp
protected function setUp()
{
if (!Intl::isExtensionLoaded()) {
$this->markTestSkipped('The intl extension is not available.');
}
if (IcuVersion::compare(Intl::getIcuVersion(), '4.4', '<', $precision = 1)) {
$this->markTestSkipped('Please change your ICU version to 4.4 or higher');
}
}
示例6: testWriteResourceBundle
public function testWriteResourceBundle()
{
// We only run tests if the intl extension is loaded...
if (!Intl::isExtensionLoaded()) {
$this->markTestSkipped('The intl extension is not available.');
}
$bundle = new \ResourceBundle('rb', __DIR__ . '/Fixtures', false);
$this->writer->write($this->directory, 'en', $bundle);
$this->assertFileEquals(__DIR__ . '/Fixtures/rb.json', $this->directory . '/en.json');
}
示例7: buildFormatter
private function buildFormatter($locale)
{
if (!Intl::isExtensionLoaded()) {
// This number formatter don't have exactly the same behavior
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
} else {
$formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
}
return $formatter;
}
示例8: getFormatter
public function getFormatter()
{
if (null === $this->formatter) {
if (!Intl::isExtensionLoaded()) {
// This number formatter don't have exactly the same behavior
$this->formatter = new NumberFormatter('en', NumberFormatter::CURRENCY);
} else {
$this->formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::CURRENCY);
}
}
return $this->formatter;
}
示例9: testWriteResourceBundle
public function testWriteResourceBundle()
{
// We only run tests if the intl extension is loaded...
if (!Intl::isExtensionLoaded()) {
$this->markTestSkipped('The intl extension is not available.');
}
if (PHP_VERSION_ID < 50315 || PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404) {
$this->markTestSkipped('ResourceBundle implements Traversable only as of PHP 5.3.15 and 5.4.4');
}
$bundle = new \ResourceBundle('rb', __DIR__ . '/Fixtures', false);
$this->writer->write($this->directory, 'en', $bundle);
$this->assertFileEquals(__DIR__ . '/Fixtures/rb.php', $this->directory . '/en.php');
}
示例10: requireFullIntl
/**
* Should be called before tests that require a feature-complete intl
* implementation.
*/
public static function requireFullIntl(\PHPUnit_Framework_TestCase $testCase, $minimumIcuVersion = null)
{
// We only run tests if the intl extension is loaded...
if (!Intl::isExtensionLoaded()) {
$testCase->markTestSkipped('Extension intl is required.');
}
self::requireIntl($testCase, $minimumIcuVersion);
// 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
}
示例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('Extension intl is required.');
}
// ... and only if the version is *one specific version*
if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) {
$testCase->markTestSkipped('ICU version ' . Intl::getIcuStubVersion() . ' 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.
// * always use the C intl classes
}
示例12: centered
If you also built the repository before, you can pass the directory where that
build is stored in the second parameter. The build directory needs to contain
the subdirectories bin/ and lib/.
For running this script, the intl extension must be loaded and all vendors
must have been installed through composer:
composer install
MESSAGE
);
}
echo LINE;
echo centered('ICU Resource Bundle Compilation') . "\n";
echo LINE;
if (!Intl::isExtensionLoaded()) {
bailout('The intl extension for PHP is not installed.');
}
$filesystem = new Filesystem();
$urls = parse_ini_file(__DIR__ . '/icu.ini');
echo "icu.ini parsed. Available versions:\n";
$maxVersion = 0;
foreach ($urls as $urlVersion => $url) {
$maxVersion = IcuVersion::compare($maxVersion, $urlVersion, '<') ? $urlVersion : $maxVersion;
echo " {$urlVersion}\n";
}
$shortIcuVersion = strip_minor_versions($maxVersion);
if ($argc >= 2) {
$sourceDir = $argv[1];
$svn = new SvnRepository($sourceDir);
echo "Using existing SVN repository at {$sourceDir}.\n";
示例13: setUp
protected function setUp()
{
if (!Intl::isExtensionLoaded()) {
$this->markTestSkipped('The intl extension is not available.');
}
}