$stubBranch = '1.0.x'; if (IcuData::isStubbed()) { bailout("Please switch to a branch of the Icu component that contains .res files (anything but {$stubBranch})."); } $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";
/** * Returns the version of the installed ICU data. * * @return string The version of the installed ICU data. */ public static function getIcuDataVersion() { if (false === self::$icuDataVersion) { self::$icuDataVersion = IcuData::getVersion(); } return self::$icuDataVersion; }