diff options
author | Mario <mario@mariovavti.com> | 2020-06-15 07:01:35 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-06-15 07:01:35 +0000 |
commit | 63a6b4a162041d8381c9e58c641b44ec5120011a (patch) | |
tree | 73386c5a5349ed5eec8bd165f68d47a6b60c6639 /vendor/commerceguys/intl/scripts | |
parent | 7270da6a28f836f94f6d98557df9532e587c3646 (diff) | |
download | volse-hubzilla-63a6b4a162041d8381c9e58c641b44ec5120011a.tar.gz volse-hubzilla-63a6b4a162041d8381c9e58c641b44ec5120011a.tar.bz2 volse-hubzilla-63a6b4a162041d8381c9e58c641b44ec5120011a.zip |
composer update commerceguys/intl
Diffstat (limited to 'vendor/commerceguys/intl/scripts')
4 files changed, 20 insertions, 199 deletions
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); @@ -76,17 +45,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. */ function export_base_data($baseData) @@ -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); @@ -58,17 +46,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. */ function export_locales($data) @@ -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 = "<?php\n\n"; $export .= '$parents = ' . str_replace(['array (', ')'], ['[', ']'], $parentLocales); $export .= "\n"; diff --git a/vendor/commerceguys/intl/scripts/generate_number_format_data.php b/vendor/commerceguys/intl/scripts/generate_number_format_data.php index a9d7d4849..0654d0ebb 100644 --- a/vendor/commerceguys/intl/scripts/generate_number_format_data.php +++ b/vendor/commerceguys/intl/scripts/generate_number_format_data.php @@ -5,20 +5,9 @@ */ 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'; -// Downloaded from https://github.com/unicode-cldr/cldr-numbers-full.git -$numbersDirectory = __DIR__ . '/assets/cldr-numbers-full/main/'; - -if (!is_dir($localeDirectory)) { - die("The $localeDirectory directory was not found"); -} -if (!is_dir($numbersDirectory)) { - die("The $numbersDirectory directory was not found"); -} if (!file_exists($enLanguages)) { die("The $enLanguages file was not found"); } @@ -165,41 +154,3 @@ function filter_duplicates(array $numberFormats) return $numberFormats; } - -/** - * 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', - // Ignored by other generation scripts, very minor locales. - 'as', 'asa', 'bem', 'ccp', 'chr', 'dav', 'dua', 'ebu', 'ewo', 'guz', 'gv', 'ii', - 'jgo', 'jmc', 'kam', 'kde', 'ki', 'kkj', 'kl', 'kln', 'ksb', 'kw', 'lag', - 'ln', 'mer', 'mgo', 'nd', 'nmg', 'nnh', 'nus', 'os', 'ps', 'rwk', 'sah', - 'saq', 'sbp', 'shi', 'sn', 'teo', 'vai', 'vun', 'xog', 'zgh', - // 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; -} |