From 62353a1fd1ad021c692eea0b2c5bac4b20ff64fb Mon Sep 17 00:00:00 2001 From: llupa Date: Tue, 4 Feb 2025 12:04:13 +0100 Subject: [PATCH] Add option to regenerate Intl data-set with Kosovo --- .../Intl/Data/Generator/RegionDataGenerator.php | 12 +++++++++++- src/Symfony/Component/Intl/README.md | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php index 745e074157974..9de74397b3d1e 100644 --- a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php @@ -56,11 +56,14 @@ class RegionDataGenerator extends AbstractDataGenerator 'QO' => true, // Outlying Oceania 'XA' => true, // Pseudo-Accents 'XB' => true, // Pseudo-Bidi - 'XK' => true, // Kosovo // Misc 'ZZ' => true, // Unknown Region ]; + private const OPTIONAL_USER_ASSIGNED = [ + 'XK' => true, // Kosovo + ]; + // @see https://en.wikipedia.org/wiki/ISO_3166-1_numeric#Withdrawn_codes private const WITHDRAWN_CODES = [ 128, // Canton and Enderbury Islands @@ -101,6 +104,13 @@ public static function isValidCountryCode(int|string|null $region): bool return false; } + if ( + isset(self::OPTIONAL_USER_ASSIGNED[$region]) + && !filter_var(getenv('ALLOW_OPTIONAL_USER_ASSIGNED'), FILTER_VALIDATE_BOOLEAN) + ) { + return false; + } + // WORLD/CONTINENT/SUBCONTINENT/GROUPING if (\is_int($region) || ctype_digit($region)) { return false; diff --git a/src/Symfony/Component/Intl/README.md b/src/Symfony/Component/Intl/README.md index 333e2fe80a812..20d598f1200fb 100644 --- a/src/Symfony/Component/Intl/README.md +++ b/src/Symfony/Component/Intl/README.md @@ -7,6 +7,13 @@ If you have the zlib extension enabled, you can compress the data by running: php vendor/symfony/intl/Resources/bin/compress +If you need Kosovo, set as a special User-Assigned code with the request of the CE Commission, +you can regenerate the data by running: + + ALLOW_OPTIONAL_USER_ASSIGNED=true php vendor/symfony/intl/Resources/bin/update-data.php + +⚠️ Careful! You might need to run this as part of your deployment flow per deployment. + Resources --------- pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy