示例#1
0
    fwrite($file, "    Locales{\n");
    foreach ($localeNames as $supportedLocale => $langName) {
        fwrite($file, "        {$supportedLocale}{\"{$langName}\"}\n");
    }
    fwrite($file, "    }\n");
    fwrite($file, "}\n");
    fclose($file);
}
// Convert generated files to binary format
// Even if the source and generated file are UTF-8 encoded, for some reason the data seems not correctly encoded, leading to
// a parse error in genrb (Stopped parsing resource with U_ILLEGAL_CHAR_FOUND). So we call the genrb passing that the source
// files are UTF-8 encoded.
if (is_icu_version_42_or_earlier($version)) {
    genrb($namesGeneratedDir, $namesDir, $icuBinPath, '-e UTF-8');
} else {
    genrb($namesGeneratedDir, $namesDir, $icuBinPath);
}
// Clean up
clear_directory($namesGeneratedDir);
rmdir($namesGeneratedDir);
// Generate the data to the stubbed intl classes We only extract data for the 'en' locale
// The extracted data is used only by the stub classes
$defaultLocale = 'en';
$currencies = array();
$currenciesMeta = array();
$defaultMeta = array();
$bundle = load_resource_bundle('supplementaldata', $currDir);
foreach ($bundle->get('CurrencyMeta') as $code => $data) {
    // The 'DEFAULT' key contains the fraction digits and the rounding increment that are common for a lot of currencies
    // Only currencies with different values are added to the icu-data (e.g: CHF and JPY)
    if ('DEFAULT' == $code) {
示例#2
0
    if (count($localeNames) === 0) {
        continue;
    }
    echo "Generating {$translatedLocale}...\n";
    $file = fopen($namesGeneratedDir . DIRECTORY_SEPARATOR . $translatedLocale . '.txt', 'w');
    fwrite($file, "{$translatedLocale}{\n");
    fwrite($file, "    Locales{\n");
    foreach ($localeNames as $supportedLocale => $langName) {
        fwrite($file, "        {$supportedLocale}{\"{$langName}\"}\n");
    }
    fwrite($file, "    }\n");
    fwrite($file, "}\n");
    fclose($file);
}
// Convert generated files to binary format
genrb($namesGeneratedDir, $namesDir);
// Clean up
clear_directory($namesGeneratedDir);
rmdir($namesGeneratedDir);
// Generate the data to the stubbed intl classes We only extract data for the 'en' locale
// The extracted data is used only by the stub classes
$defaultLocale = 'en';
$currencies = array();
$currenciesMeta = array();
$defaultMeta = array();
$bundle = load_resource_bundle('supplementaldata', __DIR__ . '/curr');
foreach ($bundle->get('CurrencyMeta') as $code => $data) {
    // The 'DEFAULT' key contains the fraction digits and the rounding increment that are common for a lot of currencies
    // Only currencies with different values are added to the icu-data (e.g: CHF and JPY)
    if ('DEFAULT' == $code) {
        $defaultMeta = array('fractionDigits' => $data[0], 'roundingIncrement' => $data[1]);