[Intl] Split update-stubs.php script into two scripts to function with the changed Icu component versioning
This commit is contained in:
parent
e2c11cb81a
commit
9dbafd7aff
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Icu\IcuData;
|
||||||
|
use Symfony\Component\Intl\Intl;
|
||||||
|
use Symfony\Component\Intl\ResourceBundle\Transformer\BundleTransformer;
|
||||||
|
use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\CurrencyBundleTransformationRule;
|
||||||
|
use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\LanguageBundleTransformationRule;
|
||||||
|
use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\LocaleBundleTransformationRule;
|
||||||
|
use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\RegionBundleTransformationRule;
|
||||||
|
use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContext;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/common.php';
|
||||||
|
require_once __DIR__ . '/autoload.php';
|
||||||
|
|
||||||
|
if (1 !== $GLOBALS['argc']) {
|
||||||
|
bailout(<<<MESSAGE
|
||||||
|
Usage: php copy-stubs-to-component.php
|
||||||
|
|
||||||
|
Copies stub files created with create-stubs.php to the Icu component.
|
||||||
|
|
||||||
|
For running this script, the intl extension must be loaded and all vendors
|
||||||
|
must have been installed through composer:
|
||||||
|
|
||||||
|
composer install --dev
|
||||||
|
|
||||||
|
MESSAGE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo LINE;
|
||||||
|
echo centered("ICU Resource Bundle Stub Update") . "\n";
|
||||||
|
echo LINE;
|
||||||
|
|
||||||
|
if (!class_exists('\Symfony\Component\Icu\IcuData')) {
|
||||||
|
bailout('You must run "composer update --dev" before running this script.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IcuData::isStubbed()) {
|
||||||
|
bailout('You should load a version of the Icu component contains stub files (i.e. *.0.x).');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filesystem = new Filesystem();
|
||||||
|
|
||||||
|
$sourceDir = sys_get_temp_dir() . '/icu-stubs';
|
||||||
|
$targetDir = IcuData::getResourceDirectory();
|
||||||
|
|
||||||
|
if (!$filesystem->exists($sourceDir)) {
|
||||||
|
bailout("The directory $sourceDir does not exist. Please run create-stubs.php first.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$filesystem->remove($targetDir);
|
||||||
|
|
||||||
|
echo "Copying files from $sourceDir to $targetDir...\n";
|
||||||
|
|
||||||
|
$filesystem->mirror($sourceDir, $targetDir);
|
||||||
|
|
||||||
|
|
||||||
|
echo "Done.\n";
|
@ -24,7 +24,7 @@ require_once __DIR__ . '/autoload.php';
|
|||||||
|
|
||||||
if (1 !== $GLOBALS['argc']) {
|
if (1 !== $GLOBALS['argc']) {
|
||||||
bailout(<<<MESSAGE
|
bailout(<<<MESSAGE
|
||||||
Usage: php update-stubs.php
|
Usage: php create-stubs.php
|
||||||
|
|
||||||
Creates resource bundle stubs from the resource bundles in the Icu component.
|
Creates resource bundle stubs from the resource bundles in the Icu component.
|
||||||
|
|
||||||
@ -49,6 +49,10 @@ if (!class_exists('\Symfony\Component\Icu\IcuData')) {
|
|||||||
bailout('You must run "composer update --dev" before running this script.');
|
bailout('You must run "composer update --dev" before running this script.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IcuData::isStubbed()) {
|
||||||
|
bailout('You should load a version of the Icu component that does not contain stub files (i.e. not *.0.x).');
|
||||||
|
}
|
||||||
|
|
||||||
$shortIcuVersionInPhp = strip_minor_versions(Intl::getIcuVersion());
|
$shortIcuVersionInPhp = strip_minor_versions(Intl::getIcuVersion());
|
||||||
$shortIcuVersionInIntlComponent = strip_minor_versions(Intl::getIcuStubVersion());
|
$shortIcuVersionInIntlComponent = strip_minor_versions(Intl::getIcuStubVersion());
|
||||||
$shortIcuVersionInIcuComponent = strip_minor_versions(IcuData::getVersion());
|
$shortIcuVersionInIcuComponent = strip_minor_versions(IcuData::getVersion());
|
||||||
@ -72,9 +76,11 @@ echo "Compiling stubs for ICU version $icuVersionInIcuComponent.\n";
|
|||||||
|
|
||||||
echo "Preparing stub creation...\n";
|
echo "Preparing stub creation...\n";
|
||||||
|
|
||||||
|
$targetDir = sys_get_temp_dir() . '/icu-stubs';
|
||||||
|
|
||||||
$context = new StubbingContext(
|
$context = new StubbingContext(
|
||||||
IcuData::getResourceDirectory(),
|
IcuData::getResourceDirectory(),
|
||||||
realpath(__DIR__ . '/../data'),
|
$targetDir,
|
||||||
new Filesystem(),
|
new Filesystem(),
|
||||||
$icuVersionInIcuComponent
|
$icuVersionInIcuComponent
|
||||||
);
|
);
|
||||||
@ -89,7 +95,7 @@ echo "Starting stub creation...\n";
|
|||||||
|
|
||||||
$transformer->createStubs($context);
|
$transformer->createStubs($context);
|
||||||
|
|
||||||
echo "Stub creation complete.\n";
|
echo "Wrote stubs to $targetDir.\n";
|
||||||
|
|
||||||
$versionFile = $context->getStubDir() . '/version.txt';
|
$versionFile = $context->getStubDir() . '/version.txt';
|
||||||
|
|
||||||
@ -98,3 +104,7 @@ file_put_contents($versionFile, "$icuVersionInIcuComponent\n");
|
|||||||
echo "Wrote $versionFile.\n";
|
echo "Wrote $versionFile.\n";
|
||||||
|
|
||||||
echo "Done.\n";
|
echo "Done.\n";
|
||||||
|
|
||||||
|
echo wordwrap("Please change the Icu component to branch 1.0.x now and run:\n", LINE_WIDTH);
|
||||||
|
|
||||||
|
echo "\n php copy-stubs-to-component.php\n";
|
Reference in New Issue
Block a user