Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Intl] Refactored Locale component into two new components Icu and Intl #7386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Apr 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5917a2e
[Intl] Refactored Locale component into two new components Icu and Intl
webmozart Mar 1, 2013
0c1fe39
[Form] Changed component to use the Intl component
webmozart Mar 15, 2013
01d0ee8
[Validator] Changed component to use the Intl component
webmozart Mar 15, 2013
b902b6b
[Locale] Added default locale
webmozart Mar 15, 2013
b60866c
[Intl] Changed Intl::getStubIcuVersion() to Intl::getIcuStubVersion()
webmozart Mar 15, 2013
5d0b849
Fixed PHPDoc
pborreli Mar 15, 2013
99f6f8a
[Form] Fixed failing tests
webmozart Mar 15, 2013
dde1d34
[Intl] Changed Intl::getIcuVersion() to return the stub version if th…
webmozart Mar 15, 2013
838798f
[Intl] Removed method IntlTestCase::skipIfInsufficientIcuVersion()
webmozart Mar 15, 2013
b9e9cb2
[Intl] Added autoload.php which was ignored by .gitignore
webmozart Mar 15, 2013
2cd1be8
[Intl] Made the $locale parameter optional in the bundle interfaces
webmozart Mar 15, 2013
0f6277f
[Locale] Adapted to latest Intl changes
webmozart Mar 15, 2013
f2a0aec
[Form] Adapted to latest Intl changes
webmozart Mar 15, 2013
209a9cb
[Validator] Adapted to latest Intl changes
webmozart Mar 15, 2013
21323ba
[Intl] Updated the README file
webmozart Mar 15, 2013
bfec58a
[Intl] Fixed flawed PHPDoc
webmozart Mar 15, 2013
9899de7
[Intl] Updated the README
webmozart Mar 15, 2013
4a5c453
[Intl] Moved the content of the README file to symfony/symfony-docs
webmozart Mar 15, 2013
467cc93
[Intl] Fixed various problems in the resource compilation process
webmozart Mar 15, 2013
f47e60a
[Intl] Fixed small bugs in the resource bundle transformation
webmozart Mar 15, 2013
dd2d013
[Intl] Improved the bundle compilation process
webmozart Mar 15, 2013
080c880
[Intl] Bumped the stub version to 50.1.2
webmozart Mar 15, 2013
f6b75b9
[Intl] Changed composer.json to disallow future versions of the Icu c…
webmozart Mar 15, 2013
1dcdcd3
[Locale] Fixed failing tests
webmozart Mar 15, 2013
17a480b
[Intl] Added IntlTestHelper class for convenience
webmozart Mar 15, 2013
c55c4a2
[Intl] Only the StubNumberFormatterTest requires stub data
webmozart Mar 15, 2013
9d9c389
[Intl] Simplified tests
webmozart Mar 15, 2013
03b78b0
[Validator] Improved tests to use the IntlTestHelper class
webmozart Mar 16, 2013
3dd75ff
[Locale] Improved tests to use the IntlTestHelper class
webmozart Mar 16, 2013
aceb20d
[Form] Improved tests to use the IntlTestHelper class
webmozart Mar 16, 2013
470927d
[Intl] Improved build scripts
webmozart Mar 16, 2013
5d17de5
[Intl] Fixed version comparisons in the transformation rules
webmozart Mar 16, 2013
a717ce9
[Intl] Removed ICU version comparisons from the tests
webmozart Mar 16, 2013
dbca3b7
[Intl] Added empty directory needed for the tests
webmozart Mar 17, 2013
0160fd5
[Intl] Moved stub data to Icu component 1.0.x
webmozart Apr 4, 2013
427d24a
[Intl] Outsourced bundle reader creation to Icu component
webmozart Apr 4, 2013
e2c11cb
[Intl] Added a check for the ICU data version to IntlTestHelper to pr…
webmozart Apr 4, 2013
9dbafd7
[Intl] Split update-stubs.php script into two scripts to function wit…
webmozart Apr 4, 2013
1249f01
[Intl] Added scripts to test the compatibility of various versions of…
webmozart Apr 5, 2013
c2d37e6
[Intl] Improved error messages in the build scripts
webmozart Apr 5, 2013
60f31d1
[Intl] Improved inline documentation
webmozart Apr 11, 2013
b4cccfd
[Intl] Removed "Stub" prefix from stub classes
webmozart Apr 11, 2013
9118b4a
[Locale] Removed "Stub" prefixes in Intl component
webmozart Apr 11, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ before_script:
- echo '' > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install
- php src/Symfony/Component/Locale/Resources/data/build-data.php
- export USE_INTL_ICU_DATA_VERSION=1
4 changes: 0 additions & 4 deletions autoload.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@ $loader = require_once __DIR__.'/vendor/autoload.php';

use Doctrine\Common\Annotations\AnnotationRegistry;

if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/src/Symfony/Component/Locale/Resources/stubs/functions.php';
}

AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"require": {
"php": ">=5.3.3",
"symfony/icu": "~1.0",
"doctrine/common": "~2.2",
"twig/twig": "~1.11",
"psr/log": "~1.0"
Expand All @@ -37,6 +38,7 @@
"symfony/framework-bundle": "self.version",
"symfony/http-foundation": "self.version",
"symfony/http-kernel": "self.version",
"symfony/intl": "self.version",
"symfony/locale": "self.version",
"symfony/monolog-bridge": "self.version",
"symfony/options-resolver": "self.version",
Expand Down Expand Up @@ -68,8 +70,9 @@
"psr-0": { "Symfony\\": "src/" },
"classmap": [
"src/Symfony/Component/HttpFoundation/Resources/stubs",
"src/Symfony/Component/Locale/Resources/stubs"
]
"src/Symfony/Component/Intl/Resources/stubs"
],
"files": [ "src/Symfony/Component/Intl/Resources/stubs/functions.php" ]
},
"minimum-stability": "dev",
"extra": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Extension\Core\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Locale\Locale;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

Expand All @@ -23,7 +24,7 @@ class CountryType extends AbstractType
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'choices' => Locale::getDisplayCountries(\Locale::getDefault()),
'choices' => Intl::getRegionBundle()->getCountryNames(),
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Extension\Core\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Locale\Locale;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

Expand All @@ -23,7 +24,7 @@ class LanguageType extends AbstractType
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'choices' => Locale::getDisplayLanguages(\Locale::getDefault()),
'choices' => Intl::getLanguageBundle()->getLanguageNames(),
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Extension\Core\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Locale\Locale;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

Expand All @@ -23,7 +24,7 @@ class LocaleType extends AbstractType
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'choices' => Locale::getDisplayLocales(\Locale::getDefault()),
'choices' => Intl::getLocaleBundle()->getLocaleNames(),
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

abstract class DateTimeTestCase extends LocalizedTestCase
abstract class DateTimeTestCase extends \PHPUnit_Framework_TestCase
{
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase
{
Expand All @@ -22,6 +23,9 @@ protected function setUp()
{
parent::setUp();

// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('de_AT');

$this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
Expand Down Expand Up @@ -57,15 +61,11 @@ public function dataProvider()
array(\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 03. Februar 2010', '2010-02-03 00:00:00 UTC'),
array(null, \IntlDateFormatter::SHORT, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'),
array(null, \IntlDateFormatter::MEDIUM, null, '03.02.2010 04:05:06', '2010-02-03 04:05:06 UTC'),
array(null, \IntlDateFormatter::LONG, null,
'03.02.2010 04:05:06 GMT'.($this->isLowerThanIcuVersion('4.8') ? '+00:00' : ''),
'2010-02-03 04:05:06 UTC'),
array(null, \IntlDateFormatter::LONG, null, '03.02.2010 04:05:06 GMT', '2010-02-03 04:05:06 UTC'),
// see below for extra test case for time format FULL
array(\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null,
'04:05:06 GMT'.($this->isLowerThanIcuVersion('4.8') ? '+00:00' : ''),
'1970-01-01 04:05:06 UTC'),
array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 GMT', '1970-01-01 04:05:06 UTC'),
array(null, null, 'yyyy-MM-dd HH:mm:00', '2010-02-03 04:05:00', '2010-02-03 04:05:00 UTC'),
array(null, null, 'yyyy-MM-dd HH:mm', '2010-02-03 04:05', '2010-02-03 04:05:00 UTC'),
array(null, null, 'yyyy-MM-dd HH', '2010-02-03 04', '2010-02-03 04:00:00 UTC'),
Expand Down Expand Up @@ -101,15 +101,9 @@ public function testTransform($dateFormat, $timeFormat, $pattern, $output, $inpu

public function testTransformFullTime()
{
if ($this->isLowerThanIcuVersion('4.0')) {
$this->markTestSkipped('Please upgrade ICU version to 4.0+');
}

$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);

$expected = $this->isLowerThanIcuVersion('4.8') ? '03.02.2010 04:05:06 GMT+00:00' : '03.02.2010 04:05:06 GMT';

$this->assertEquals($expected, $transformer->transform($this->dateTime));
$this->assertEquals('03.02.2010 04:05:06 GMT', $transformer->transform($this->dateTime));
}

public function testTransformToDifferentLocale()
Expand All @@ -118,7 +112,7 @@ public function testTransformToDifferentLocale()

$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');

$this->assertEquals('Feb 3, 2010 4:05 AM', $transformer->transform($this->dateTime));
$this->assertEquals('Feb 3, 2010, 4:05 AM', $transformer->transform($this->dateTime));
}

public function testTransformEmpty()
Expand Down Expand Up @@ -188,10 +182,6 @@ public function testReverseTransform($dateFormat, $timeFormat, $pattern, $input,

public function testReverseTransformFullTime()
{
if ($this->isLowerThanIcuVersion('4.0')) {
$this->markTestSkipped('Please upgrade ICU version to 4.0+');
}

$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL);

$this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('03.02.2010 04:05:06 GMT+00:00'));
Expand All @@ -203,7 +193,7 @@ public function testReverseTransformFromDifferentLocale()

$transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');

$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010 04:05 AM'));
$this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM'));
}

public function testReverseTransformWithDifferentTimezones()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class IntegerToLocalizedStringTransformerTest extends LocalizedTestCase
class IntegerToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
parent::setUp();

// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('de_AT');
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class MoneyToLocalizedStringTransformerTest extends LocalizedTestCase
class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
parent::setUp();

// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('de_AT');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class NumberToLocalizedStringTransformerTest extends LocalizedTestCase
class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
parent::setUp();

// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('de_AT');
}

Expand Down Expand Up @@ -96,10 +100,6 @@ public function testReverseTransformWithGrouping()

public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
{
if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
}

\Locale::setDefault('fr');
$transformer = new NumberToLocalizedStringTransformer(null, true);

Expand All @@ -117,10 +117,6 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot()
*/
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
{
if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
}

$transformer = new NumberToLocalizedStringTransformer(null, true);

$transformer->reverseTransform('1.234.5');
Expand All @@ -131,10 +127,6 @@ public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot()
*/
public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep()
{
if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
}

$transformer = new NumberToLocalizedStringTransformer(null, true);

$transformer->reverseTransform('1234.5');
Expand All @@ -151,11 +143,7 @@ public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupin

public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
{
if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
}

\Locale::setDefault('ak');
\Locale::setDefault('bg');
$transformer = new NumberToLocalizedStringTransformer(null, true);

// completely valid format
Expand All @@ -172,10 +160,6 @@ public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma()
*/
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
{
if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
}

\Locale::setDefault('en');
$transformer = new NumberToLocalizedStringTransformer(null, true);

Expand All @@ -187,10 +171,6 @@ public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma()
*/
public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep()
{
if ($this->isLowerThanIcuVersion('4.7')) {
$this->markTestSkipped('Please upgrade ICU version to 4.7+');
}

\Locale::setDefault('en');
$transformer = new NumberToLocalizedStringTransformer(null, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;

use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer;
use Symfony\Component\Intl\Util\IntlTestHelper;

class PercentToLocalizedStringTransformerTest extends LocalizedTestCase
class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
parent::setUp();

// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this);

\Locale::setDefault('de_AT');
}

Expand Down
Loading