Ejemplo n.º 1
0
 protected function setUp()
 {
     parent::setUp();
     $this->resDir = IcuData::getResourceDirectory() . '/region';
     $this->reader = $this->getMock('Symfony\\Component\\Intl\\ResourceBundle\\Reader\\StructuredBundleReaderInterface');
     $this->bundle = new IcuRegionBundle($this->reader);
 }
Ejemplo n.º 2
0
 public function __construct(StructuredBundleReaderInterface $reader)
 {
     parent::__construct(realpath(IcuData::getResourceDirectory() . '/region'), $reader);
 }
Ejemplo n.º 3
0
 public static function getDataDirectory()
 {
     return IcuData::getResourceDirectory();
 }
Ejemplo n.º 4
0
}
$shortIcuVersionInPhp = strip_minor_versions(Intl::getIcuVersion());
$shortIcuVersionInIntlComponent = strip_minor_versions(Intl::getIcuStubVersion());
$shortIcuVersionInIcuComponent = strip_minor_versions(IcuData::getVersion());
if ($shortIcuVersionInPhp !== $shortIcuVersionInIcuComponent) {
    bailout("The ICU version of the component ({$shortIcuVersionInIcuComponent}) does not match the ICU version in the intl extension ({$shortIcuVersionInPhp}).");
}
if ($shortIcuVersionInIntlComponent !== $shortIcuVersionInIcuComponent) {
    bailout("The ICU version of the component ({$shortIcuVersionInIcuComponent}) does not match the ICU version of the stub classes in the Intl component ({$shortIcuVersionInIntlComponent}).");
}
echo wordwrap("Make sure that you don't have any ICU development files " . "installed. If the build fails, try to run:\n", LINE_WIDTH);
echo "\n    sudo apt-get remove libicu-dev\n\n";
$icuVersionInIcuComponent = IcuData::getVersion();
echo "Compiling stubs for ICU version {$icuVersionInIcuComponent}.\n";
echo "Preparing stub creation...\n";
$targetDir = sys_get_temp_dir() . '/icu-stubs';
$context = new StubbingContext(IcuData::getResourceDirectory(), $targetDir, new Filesystem(), $icuVersionInIcuComponent);
$transformer = new BundleTransformer();
$transformer->addRule(new LanguageBundleTransformationRule());
$transformer->addRule(new RegionBundleTransformationRule());
$transformer->addRule(new CurrencyBundleTransformationRule());
$transformer->addRule(new LocaleBundleTransformationRule());
echo "Starting stub creation...\n";
$transformer->createStubs($context);
echo "Wrote stubs to {$targetDir}.\n";
$versionFile = $context->getStubDir() . '/version.txt';
file_put_contents($versionFile, "{$icuVersionInIcuComponent}\n");
echo "Wrote {$versionFile}.\n";
echo "Done.\n";
echo wordwrap("Please change the Icu component to branch {$stubBranch} now and run:\n", LINE_WIDTH);
echo "\n    php copy-stubs-to-component.php\n";
Ejemplo n.º 5
0
    echo " ok.\n";
    echo "[4/5] libicutu.so...";
    cd($sourceDir . '/tools/toolutil');
    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
    echo "[5/5] genrb...";
    cd($sourceDir . '/tools/genrb');
    run('make 2>&1 && make install 2>&1');
    echo " ok.\n";
}
$genrb = $buildDir . '/bin/genrb';
$genrbEnv = 'LD_LIBRARY_PATH=' . $buildDir . '/lib ';
echo "Using {$genrb}.\n";
$icuVersionInDownload = get_icu_version_from_genrb($genrbEnv . ' ' . $genrb);
echo "Preparing resource bundle compilation (version {$icuVersionInDownload})...\n";
$context = new CompilationContext($sourceDir . '/data', IcuData::getResourceDirectory(), $filesystem, new BundleCompiler($genrb, $genrbEnv), $icuVersionInDownload);
$transformer = new BundleTransformer();
$transformer->addRule(new LanguageBundleTransformationRule());
$transformer->addRule(new RegionBundleTransformationRule());
$transformer->addRule(new CurrencyBundleTransformationRule());
$transformer->addRule(new LocaleBundleTransformationRule());
echo "Starting resource bundle compilation. This may take a while...\n";
$transformer->compileBundles($context);
echo "Resource bundle compilation complete.\n";
$svnInfo = <<<SVN_INFO
SVN information
===============

URL: {$svn->getUrl()}
Revision: {$svn->getLastCommit()->getRevision()}
Author: {$svn->getLastCommit()->getAuthor()}
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.');
}
$stubBranch = '1.0.x';
if (!IcuData::isStubbed()) {
    bailout("Please switch to the Icu component branch {$stubBranch}.");
}
$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";
Ejemplo n.º 7
0
 /**
  * Returns a resource bundle reader for .php resource bundle files.
  *
  * @return ResourceBundle\Reader\StructuredBundleReaderInterface The resource reader.
  */
 private static function getBundleReader()
 {
     if (null === self::$bundleReader) {
         self::$bundleReader = new StructuredBundleReader(new BufferedBundleReader(IcuData::getBundleReader(), self::BUFFER_SIZE));
     }
     return self::$bundleReader;
 }
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Symfony\Component\Icu\IcuData;
use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader;
require_once __DIR__ . '/../common.php';
require_once __DIR__ . '/../autoload.php';
$reader = new BinaryBundleReader();
$reader->read(IcuData::getResourceDirectory() . '/curr', 'en');
$reader->read(IcuData::getResourceDirectory() . '/lang', 'en');
$reader->read(IcuData::getResourceDirectory() . '/locales', 'en');
$reader->read(IcuData::getResourceDirectory() . '/region', 'en');