Merge branch '3.4' into 4.2
* 3.4: [Intl] Cleanup
This commit is contained in:
commit
4304fb8e05
@ -1,91 +0,0 @@
|
||||
Contributing to the Intl component
|
||||
==================================
|
||||
|
||||
A very good way of contributing to the Intl component is by updating the
|
||||
included data for the ICU version you have installed on your system.
|
||||
|
||||
Preparation
|
||||
-----------
|
||||
|
||||
To prepare, you need to install the development dependencies of the component.
|
||||
|
||||
$ cd /path/to/Symfony/Component/Intl
|
||||
$ composer install
|
||||
|
||||
Determining your ICU version
|
||||
---------------------------
|
||||
|
||||
The ICU version installed in your PHP environment can be found by running
|
||||
icu-version.php:
|
||||
|
||||
$ php Resources/bin/icu-version.php
|
||||
|
||||
Updating the ICU data
|
||||
---------------------
|
||||
|
||||
To update the data files, run the update-icu-component.php script:
|
||||
|
||||
$ php Resources/bin/update-icu-component.php
|
||||
|
||||
The script needs the binaries "svn" and "make" to be available on your system.
|
||||
It will download the latest version of the ICU sources for the ICU version
|
||||
installed in your PHP environment. The script will then compile the "genrb"
|
||||
binary and use it to compile the ICU data files to binaries. The binaries are
|
||||
copied to the Resources/ directory of the Icu component found in the
|
||||
vendor/symfony/icu/ directory.
|
||||
|
||||
Updating the stub data
|
||||
----------------------
|
||||
|
||||
In the previous step you updated the Icu component for the ICU version
|
||||
installed on your system. If you are using the latest ICU version, you should
|
||||
also create the stub data files which will be used by people who don't have
|
||||
the intl extension installed.
|
||||
|
||||
To update the stub files, run the update-stubs.php script:
|
||||
|
||||
$ php Resources/bin/update-stubs.php
|
||||
|
||||
The script will fail if you don't have the latest ICU version. If you want to
|
||||
upgrade the ICU version, adjust the return value of the
|
||||
`Intl::getIcuStubVersion()` before you run the script.
|
||||
|
||||
The script creates copies of the binary resource bundles in the Icu component
|
||||
and stores them in the Resources/ directory of the Intl component. The copies
|
||||
are made for the locale "en" only and are stored in .php files, so that they
|
||||
can be read even if the intl extension is not available.
|
||||
|
||||
Creating a pull request
|
||||
-----------------------
|
||||
|
||||
You need to create up to two pull requests:
|
||||
|
||||
* If you updated the Icu component, you need to push that change and create a
|
||||
pull request in the `symfony/Icu` repository. Make sure to submit the pull
|
||||
request to the correct master branch. If you updated the ICU data for version
|
||||
4.8, your pull request goes to branch `48-master`, for version 49 to
|
||||
`49-master` and so on.
|
||||
|
||||
* If you updated the stub files of the Intl component, you need to push that
|
||||
change and create a pull request in the `symfony/symfony` repository. The
|
||||
pull request should be based on the `master` branch.
|
||||
|
||||
Combining .res files to a .dat-package
|
||||
--------------------------------------
|
||||
|
||||
The individual *.res files can be combined into a single .dat-file.
|
||||
Unfortunately, PHP's `ResourceBundle` class is currently not able to handle
|
||||
.dat-files.
|
||||
|
||||
Once it is, the following steps have to be followed to build the .dat-file:
|
||||
|
||||
1. Package the resource bundles into a single file
|
||||
|
||||
$ find . -name *.res | sed -e "s/\.\///g" > packagelist.txt
|
||||
$ pkgdata -p region -T build -d . packagelist.txt
|
||||
|
||||
2. Clean up
|
||||
|
||||
$ rm -rf build packagelist.txt
|
||||
|
||||
3. You can now move region.dat to replace the version bundled with Symfony.
|
@ -25,37 +25,20 @@ use Symfony\Component\Intl\Data\Util\LocaleScanner;
|
||||
*/
|
||||
class CurrencyDataGenerator extends AbstractDataGenerator
|
||||
{
|
||||
const UNKNOWN_CURRENCY_ID = 'XXX';
|
||||
const EUROPEAN_COMPOSITE_UNIT_ID = 'XBA';
|
||||
const EUROPEAN_MONETARY_UNIT_ID = 'XBB';
|
||||
const EUROPEAN_UNIT_OF_ACCOUNT_XBC_ID = 'XBC';
|
||||
const EUROPEAN_UNIT_OF_ACCOUNT_XBD_ID = 'XBD';
|
||||
const TESTING_CURRENCY_CODE_ID = 'XTS';
|
||||
const ADB_UNIT_OF_ACCOUNT_ID = 'XUA';
|
||||
const GOLD_ID = 'XAU';
|
||||
const SILVER_ID = 'XAG';
|
||||
const PLATINUM_ID = 'XPT';
|
||||
const PALLADIUM_ID = 'XPD';
|
||||
const SUCRE_ID = 'XSU';
|
||||
const SPECIAL_DRAWING_RIGHTS_ID = 'XDR';
|
||||
|
||||
/**
|
||||
* Monetary units excluded from generation.
|
||||
*/
|
||||
private static $blacklist = [
|
||||
self::UNKNOWN_CURRENCY_ID => true,
|
||||
self::EUROPEAN_COMPOSITE_UNIT_ID => true,
|
||||
self::EUROPEAN_MONETARY_UNIT_ID => true,
|
||||
self::EUROPEAN_UNIT_OF_ACCOUNT_XBC_ID => true,
|
||||
self::EUROPEAN_UNIT_OF_ACCOUNT_XBD_ID => true,
|
||||
self::TESTING_CURRENCY_CODE_ID => true,
|
||||
self::ADB_UNIT_OF_ACCOUNT_ID => true,
|
||||
self::GOLD_ID => true,
|
||||
self::SILVER_ID => true,
|
||||
self::PLATINUM_ID => true,
|
||||
self::PALLADIUM_ID => true,
|
||||
self::SUCRE_ID => true,
|
||||
self::SPECIAL_DRAWING_RIGHTS_ID => true,
|
||||
'XBA' => true, // European Composite Unit
|
||||
'XBB' => true, // European Monetary Unit
|
||||
'XBC' => true, // European Unit of Account (XBC)
|
||||
'XBD' => true, // European Unit of Account (XBD)
|
||||
'XUA' => true, // ADB Unit of Account
|
||||
'XAU' => true, // Gold
|
||||
'XAG' => true, // Silver
|
||||
'XPT' => true, // Platinum
|
||||
'XPD' => true, // Palladium
|
||||
'XSU' => true, // Sucre
|
||||
'XDR' => true, // Special Drawing Rights
|
||||
'XTS' => true, // Testing Currency Code
|
||||
'XXX' => true, // Unknown Currency
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -27,32 +27,18 @@ use Symfony\Component\Intl\Data\Util\LocaleScanner;
|
||||
*/
|
||||
class RegionDataGenerator extends AbstractDataGenerator
|
||||
{
|
||||
const UNKNOWN_REGION_ID = 'ZZ';
|
||||
const OUTLYING_OCEANIA_REGION_ID = 'QO';
|
||||
const EUROPEAN_UNION_ID = 'EU';
|
||||
const NETHERLANDS_ANTILLES_ID = 'AN';
|
||||
const BOUVET_ISLAND_ID = 'BV';
|
||||
const HEARD_MCDONALD_ISLANDS_ID = 'HM';
|
||||
const CLIPPERTON_ISLAND_ID = 'CP';
|
||||
const EUROZONE_ID = 'EZ';
|
||||
const UNITED_NATIONS_ID = 'UN';
|
||||
|
||||
/**
|
||||
* Regions excluded from generation.
|
||||
*/
|
||||
private static $blacklist = [
|
||||
self::UNKNOWN_REGION_ID => true,
|
||||
// Look like countries, but are sub-continents
|
||||
self::OUTLYING_OCEANIA_REGION_ID => true,
|
||||
self::EUROPEAN_UNION_ID => true,
|
||||
self::EUROZONE_ID => true,
|
||||
self::UNITED_NATIONS_ID => true,
|
||||
// No longer exists
|
||||
self::NETHERLANDS_ANTILLES_ID => true,
|
||||
'QO' => true, // Outlying Oceania
|
||||
'EU' => true, // European Union
|
||||
'EZ' => true, // Eurozone
|
||||
'UN' => true, // United Nations
|
||||
// Uninhabited islands
|
||||
self::BOUVET_ISLAND_ID => true,
|
||||
self::HEARD_MCDONALD_ISLANDS_ID => true,
|
||||
self::CLIPPERTON_ISLAND_ID => true,
|
||||
'BV' => true, // Bouvet Island
|
||||
'HM' => true, // Heard & McDonald Islands
|
||||
'CP' => true, // Clipperton Island
|
||||
// Misc
|
||||
'ZZ' => true, // Unknown Region
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
|
||||
use Symfony\Component\Intl\Exception\MissingResourceException;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* Data provider for currency-related data.
|
||||
@ -53,7 +52,7 @@ class CurrencyDataProvider
|
||||
public function getSymbol($currency, $displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
return $this->reader->readEntry($this->path, $displayLocale, ['Names', $currency, static::INDEX_SYMBOL]);
|
||||
@ -62,7 +61,7 @@ class CurrencyDataProvider
|
||||
public function getName($currency, $displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
return $this->reader->readEntry($this->path, $displayLocale, ['Names', $currency, static::INDEX_NAME]);
|
||||
@ -71,7 +70,7 @@ class CurrencyDataProvider
|
||||
public function getNames($displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Intl\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* Data provider for language-related ICU data.
|
||||
@ -51,7 +50,7 @@ class LanguageDataProvider
|
||||
public function getName($language, $displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
return $this->reader->readEntry($this->path, $displayLocale, ['Names', $language]);
|
||||
@ -60,7 +59,7 @@ class LanguageDataProvider
|
||||
public function getNames($displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
$languages = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Intl\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* Data provider for locale-related ICU data.
|
||||
@ -57,7 +56,7 @@ class LocaleDataProvider
|
||||
public function getName($locale, $displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
return $this->reader->readEntry($this->path, $displayLocale, ['Names', $locale]);
|
||||
@ -66,7 +65,7 @@ class LocaleDataProvider
|
||||
public function getNames($displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
$names = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Intl\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* Data provider for region-related ICU data.
|
||||
@ -46,7 +45,7 @@ class RegionDataProvider
|
||||
public function getName($region, $displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
return $this->reader->readEntry($this->path, $displayLocale, ['Names', $region]);
|
||||
@ -55,7 +54,7 @@ class RegionDataProvider
|
||||
public function getNames($displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
$names = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Intl\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* Data provider for script-related ICU data.
|
||||
@ -46,7 +45,7 @@ class ScriptDataProvider
|
||||
public function getName($script, $displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
return $this->reader->readEntry($this->path, $displayLocale, ['Names', $script]);
|
||||
@ -55,7 +54,7 @@ class ScriptDataProvider
|
||||
public function getNames($displayLocale = null)
|
||||
{
|
||||
if (null === $displayLocale) {
|
||||
$displayLocale = Locale::getDefault();
|
||||
$displayLocale = \Locale::getDefault();
|
||||
}
|
||||
|
||||
$names = $this->reader->readEntry($this->path, $displayLocale, ['Names']);
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Provider\CurrencyDataProvider;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
@ -631,7 +630,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNamesDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$this->assertSame(
|
||||
$this->dataProvider->getNames('de_AT'),
|
||||
@ -670,7 +669,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNameDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$expected = $this->dataProvider->getNames('de_AT');
|
||||
$actual = [];
|
||||
|
@ -703,7 +703,7 @@ abstract class AbstractDataProviderTest extends TestCase
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
Locale::setDefault('en');
|
||||
\Locale::setDefault('en');
|
||||
Locale::setDefaultFallback('en');
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Provider\LanguageDataProvider;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
@ -862,7 +861,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNamesDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$this->assertSame(
|
||||
$this->dataProvider->getNames('de_AT'),
|
||||
@ -898,7 +897,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNameDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$names = $this->dataProvider->getNames('de_AT');
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Provider\LocaleDataProvider;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
@ -64,7 +63,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNamesDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$this->assertSame(
|
||||
$this->dataProvider->getNames('de_AT'),
|
||||
@ -100,7 +99,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNameDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$names = $this->dataProvider->getNames('de_AT');
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Provider\RegionDataProvider;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
@ -316,7 +315,7 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNamesDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$this->assertSame(
|
||||
$this->dataProvider->getNames('de_AT'),
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Component\Intl\Tests\Data\Provider;
|
||||
|
||||
use Symfony\Component\Intl\Data\Provider\ScriptDataProvider;
|
||||
use Symfony\Component\Intl\Intl;
|
||||
use Symfony\Component\Intl\Locale;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
@ -255,7 +254,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNamesDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$this->assertSame(
|
||||
$this->dataProvider->getNames('de_AT'),
|
||||
@ -291,7 +290,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
|
||||
|
||||
public function testGetNameDefaultLocale()
|
||||
{
|
||||
Locale::setDefault('de_AT');
|
||||
\Locale::setDefault('de_AT');
|
||||
|
||||
$names = $this->dataProvider->getNames('de_AT');
|
||||
|
||||
|
Reference in New Issue
Block a user