Skip to content

[Intl] Add option to regenerate Intl data-set with Kosovo #59693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------

Expand Down
Loading