From 63a6b4a162041d8381c9e58c641b44ec5120011a Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 15 Jun 2020 07:01:35 +0000 Subject: composer update commerceguys/intl --- .../intl/scripts/generate_currency_data.php | 80 +--------------------- .../intl/scripts/generate_language_data.php | 78 +++------------------ .../intl/scripts/generate_locale_data.php | 10 ++- .../intl/scripts/generate_number_format_data.php | 51 +------------- 4 files changed, 20 insertions(+), 199 deletions(-) (limited to 'vendor/commerceguys/intl/scripts') diff --git a/vendor/commerceguys/intl/scripts/generate_currency_data.php b/vendor/commerceguys/intl/scripts/generate_currency_data.php index 9dfc262e1..22c33c63b 100644 --- a/vendor/commerceguys/intl/scripts/generate_currency_data.php +++ b/vendor/commerceguys/intl/scripts/generate_currency_data.php @@ -7,38 +7,7 @@ * deprecated currencies, unlike CLDR (v25 has 139 deprecated entries). */ -set_time_limit(0); -require __DIR__ . '/../vendor/autoload.php'; - -// Downloaded from http://www.currency-iso.org/en/home/tables/table-a1.html -$isoCurrencies = __DIR__ . '/assets/c2.xml'; -// Downloaded from https://github.com/unicode-cldr/cldr-numbers-full.git -$numbersDirectory = __DIR__ . '/assets/cldr-numbers-full/main/'; -$cldrCurrencies = $numbersDirectory . 'en/currencies.json'; -// Downloaded from https://github.com/unicode-cldr/cldr-core.git -$currencyData = __DIR__ . '/assets/cldr-core/supplemental/currencyData.json'; -// Downloaded from https://github.com/unicode-cldr/cldr-localenames-full.git -$localeDirectory = __DIR__ . '/assets/cldr-localenames-full/main/'; -if (!file_exists($isoCurrencies)) { - die("The $isoCurrencies file was not found"); -} -if (!file_exists($cldrCurrencies)) { - die("The $cldrCurrencies file was not found"); -} -if (!file_exists($currencyData)) { - die("The $currencyData file was not found"); -} -if (!function_exists('collator_create')) { - // Reimplementing intl's collator would be a huge undertaking, so we - // use it instead to presort the generated locale specific data. - die('The intl extension was not found.'); -} -if (!is_dir($localeDirectory)) { - die("The $localeDirectory directory was not found"); -} -if (!is_dir($numbersDirectory)) { - die("The $numbersDirectory directory was not found"); -} +require __DIR__ . '/generate_base.php'; $currencyData = json_decode(file_get_contents($currencyData), true); $isoData = simplexml_load_file($isoCurrencies); @@ -75,17 +44,6 @@ file_put_contents(__DIR__ . '/currency_data.php', $data); echo "Done.\n"; -/** - * Converts the provided data into json and writes it to the disk. - */ -function file_put_json($filename, $data) -{ - $data = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); - // Indenting with tabs instead of 4 spaces gives us 20% smaller files. - $data = str_replace(' ', "\t", $data); - file_put_contents($filename, $data); -} - /** * Exports base data. */ @@ -213,6 +171,7 @@ function generate_localizations(array $baseData) return $localizations; } + /** * Filters out duplicate localizations (same as their parent locale). * @@ -242,38 +201,3 @@ function filter_duplicate_localizations(array $localizations) return $localizations; } - -/** - * Creates a list of available locales. - */ -function discover_locales() -{ - global $localeDirectory; - - // Locales listed without a "-" match all variants. - // Locales listed with a "-" match only those exact ones. - $ignoredLocales = [ - // Interlingua is a made up language. - 'ia', - // Valencian differs from its parent only by a single character (è/é). - 'ca-ES-VALENCIA', - // Special "grouping" locales. - 'root', 'en-US-POSIX', - ]; - - // Gather available locales. - $locales = []; - if ($handle = opendir($localeDirectory)) { - while (false !== ($entry = readdir($handle))) { - if (substr($entry, 0, 1) != '.') { - $entryParts = explode('-', $entry); - if (!in_array($entry, $ignoredLocales) && !in_array($entryParts[0], $ignoredLocales)) { - $locales[] = $entry; - } - } - } - closedir($handle); - } - - return $locales; -} diff --git a/vendor/commerceguys/intl/scripts/generate_language_data.php b/vendor/commerceguys/intl/scripts/generate_language_data.php index a7dbd836e..c6215e3fd 100644 --- a/vendor/commerceguys/intl/scripts/generate_language_data.php +++ b/vendor/commerceguys/intl/scripts/generate_language_data.php @@ -8,24 +8,12 @@ * for which CLDR itself has translations are listed. */ -set_time_limit(0); -require __DIR__ . '/../vendor/autoload.php'; +require __DIR__ . '/generate_base.php'; -// Downloaded from https://github.com/unicode-cldr/cldr-localenames-full.git -$localeDirectory = __DIR__ . '/assets/cldr-localenames-full/main/'; $enLanguages = $localeDirectory . 'en/languages.json'; - -if (!is_dir($localeDirectory)) { - die("The $localeDirectory directory was not found"); -} if (!file_exists($enLanguages)) { die("The $enLanguages file was not found"); } -if (!function_exists('collator_create')) { - // Reimplementing intl's collator would be a huge undertaking, so we - // use it instead to presort the generated locale specific data. - die('The intl extension was not found.'); -} $languages = generate_languages(); $languages = filter_duplicate_localizations($languages); @@ -57,17 +45,6 @@ file_put_contents(__DIR__ . '/language_data.php', $data); echo "Done.\n"; -/** - * Converts the provided data into json and writes it to the disk. - */ -function file_put_json($filename, $data) -{ - $data = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); - // Indenting with tabs instead of 4 spaces gives us 20% smaller files. - $data = str_replace(' ', "\t", $data); - file_put_contents($filename, $data); -} - /** * Exports locales. */ @@ -98,12 +75,13 @@ function generate_languages() $index = array_search('en', $locales); unset($locales[$index]); array_unshift($locales, 'en'); - // The filtering of the language list against the locale list can be - // too strict, filtering out languages that should be in the final list. - // This override ensures that such cases are covered. - $explicitlyAllowed = ['wa']; + // Skip all languages that aren't an available locale at the same time. + // This reduces the language list from about 515 to about 185 languages. + $allowedLanguages = scandir($localeDirectory); + $allowedLanguages[] = 'wa'; + $allowedLanguages = array_diff($allowedLanguages, ['eo', 'ia', 'vo', 'cu', 'gv', 'prg', 'root']); // Languages that are untranslated in most locales (as of CLDR v34). - $explicitlyIgnored = ['ccp', 'fa-AF']; + $allowedLanguages = array_diff($allowedLanguages, ['ccp', 'fa-AF']); $untranslatedCounts = []; $languages = []; @@ -111,12 +89,7 @@ function generate_languages() $data = json_decode(file_get_contents($localeDirectory . $locale . '/languages.json'), true); $data = $data['main'][$locale]['localeDisplayNames']['languages']; foreach ($data as $languageCode => $languageName) { - // Skip all languages that aren't an available locale at the same time. - // This reduces the language list from about 515 to about 185 languages. - if (!in_array($languageCode, $locales) && !in_array($languageCode, $explicitlyAllowed)) { - continue; - } - if (in_array($languageCode, $explicitlyIgnored)) { + if (!in_array($languageCode, $allowedLanguages)) { continue; } @@ -180,38 +153,3 @@ function filter_duplicate_localizations(array $localizations) return $localizations; } - -/** - * Creates a list of available locales. - */ -function discover_locales() -{ - global $localeDirectory; - - // Locales listed without a "-" match all variants. - // Locales listed with a "-" match only those exact ones. - $ignoredLocales = [ - // Interlingua is a made up language. - 'ia', - // Valencian differs from its parent only by a single character (è/é). - 'ca-ES-VALENCIA', - // Special "grouping" locales. - 'root', 'en-US-POSIX', - ]; - - // Gather available locales. - $locales = []; - if ($handle = opendir($localeDirectory)) { - while (false !== ($entry = readdir($handle))) { - if (substr($entry, 0, 1) != '.') { - $entryParts = explode('-', $entry); - if (!in_array($entry, $ignoredLocales) && !in_array($entryParts[0], $ignoredLocales)) { - $locales[] = $entry; - } - } - } - closedir($handle); - } - - return $locales; -} diff --git a/vendor/commerceguys/intl/scripts/generate_locale_data.php b/vendor/commerceguys/intl/scripts/generate_locale_data.php index 4e2b617b8..d1e77b8d8 100644 --- a/vendor/commerceguys/intl/scripts/generate_locale_data.php +++ b/vendor/commerceguys/intl/scripts/generate_locale_data.php @@ -4,11 +4,19 @@ * Generates the $parents array for the Locale class. */ +require __DIR__ . '/generate_base.php'; + $parentLocales = __DIR__ . '/assets/cldr-core/supplemental/parentLocales.json'; $parentLocales = json_decode(file_get_contents($parentLocales), true); $parentLocales = $parentLocales['supplemental']['parentLocales']['parentLocale']; -$parentLocales = var_export($parentLocales, true) . ';'; +foreach ($parentLocales as $locale => $parentLocale) { + $localeParts = explode('-', $locale); + if (in_array($localeParts[0], $ignoredLocales)) { + unset($parentLocales[$locale]); + } +} +$parentLocales = var_export($parentLocales, true) . ';'; $export = "