Skip to content

Commit

Permalink
[Intl] Exclude invalid/unknown codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed May 2, 2019
1 parent 446480e commit 5b24cb6
Show file tree
Hide file tree
Showing 175 changed files with 151 additions and 393 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/Intl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CHANGELOG
* added `Locales` in favor of `Intl::getLocaleBundle()`
* added `Regions` in favor of `Intl::getRegionBundle()`
* added `Timezones`
* excluded country codes `XA` and `XB`
* excluded script code `Zzzz`

4.2.0
-----
Expand Down
43 changes: 13 additions & 30 deletions src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,20 @@
*/
class CurrencyDataGenerator extends AbstractDataGenerator
{
const UNKNOWN_CURRENCY_ID = 'XXX';
const EUROPEAN_COMPOSITE_UNIT_ID = 'XBA';
const EUROPEAN_MONETARY_UNIT_ID = 'XBB';
const EUROPEAN_UNIT_OF_ACCOUNT_XBC_ID = 'XBC';
const EUROPEAN_UNIT_OF_ACCOUNT_XBD_ID = 'XBD';
const TESTING_CURRENCY_CODE_ID = 'XTS';
const ADB_UNIT_OF_ACCOUNT_ID = 'XUA';
const GOLD_ID = 'XAU';
const SILVER_ID = 'XAG';
const PLATINUM_ID = 'XPT';
const PALLADIUM_ID = 'XPD';
const SUCRE_ID = 'XSU';
const SPECIAL_DRAWING_RIGHTS_ID = 'XDR';

/**
* Monetary units excluded from generation.
*/
private static $blacklist = [
self::UNKNOWN_CURRENCY_ID => true,
self::EUROPEAN_COMPOSITE_UNIT_ID => true,
self::EUROPEAN_MONETARY_UNIT_ID => true,
self::EUROPEAN_UNIT_OF_ACCOUNT_XBC_ID => true,
self::EUROPEAN_UNIT_OF_ACCOUNT_XBD_ID => true,
self::TESTING_CURRENCY_CODE_ID => true,
self::ADB_UNIT_OF_ACCOUNT_ID => true,
self::GOLD_ID => true,
self::SILVER_ID => true,
self::PLATINUM_ID => true,
self::PALLADIUM_ID => true,
self::SUCRE_ID => true,
self::SPECIAL_DRAWING_RIGHTS_ID => true,
'XBA' => true, // European Composite Unit
'XBB' => true, // European Monetary Unit
'XBC' => true, // European Unit of Account (XBC)
'XBD' => true, // European Unit of Account (XBD)
'XUA' => true, // ADB Unit of Account
'XAU' => true, // Gold
'XAG' => true, // Silver
'XPT' => true, // Platinum
'XPD' => true, // Palladium
'XSU' => true, // Sucre
'XDR' => true, // Special Drawing Rights
'XTS' => true, // Testing Currency Code
'XXX' => true, // Unknown Currency
];

/**
Expand Down
34 changes: 11 additions & 23 deletions src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,20 @@
*/
class RegionDataGenerator extends AbstractDataGenerator
{
const UNKNOWN_REGION_ID = 'ZZ';
const OUTLYING_OCEANIA_REGION_ID = 'QO';
const EUROPEAN_UNION_ID = 'EU';
const NETHERLANDS_ANTILLES_ID = 'AN';
const BOUVET_ISLAND_ID = 'BV';
const HEARD_MCDONALD_ISLANDS_ID = 'HM';
const CLIPPERTON_ISLAND_ID = 'CP';
const EUROZONE_ID = 'EZ';
const UNITED_NATIONS_ID = 'UN';

/**
* Regions excluded from generation.
*/
private static $blacklist = [
self::UNKNOWN_REGION_ID => true,
// Look like countries, but are sub-continents
self::OUTLYING_OCEANIA_REGION_ID => true,
self::EUROPEAN_UNION_ID => true,
self::EUROZONE_ID => true,
self::UNITED_NATIONS_ID => true,
// No longer exists
self::NETHERLANDS_ANTILLES_ID => true,
'QO' => true, // Outlying Oceania
'EU' => true, // European Union
'EZ' => true, // Eurozone
'UN' => true, // United Nations
// Uninhabited islands
self::BOUVET_ISLAND_ID => true,
self::HEARD_MCDONALD_ISLANDS_ID => true,
self::CLIPPERTON_ISLAND_ID => true,
'BV' => true, // Bouvet Island
'HM' => true, // Heard & McDonald Islands
'CP' => true, // Clipperton Island
// Misc
'XA' => true, // Pseudo-Accents
'XB' => true, // Pseudo-Bidi
'ZZ' => true, // Unknown Region
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
*/
class ScriptDataGenerator extends AbstractDataGenerator
{
private static $blacklist = [
'Zzzz' => true, // Unknown Script
];

/**
* Collects all available language codes.
*
Expand Down Expand Up @@ -66,7 +70,7 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir
if (isset($localeBundle['Scripts']) && null !== $localeBundle['Scripts']) {
$data = [
'Version' => $localeBundle['Version'],
'Names' => iterator_to_array($localeBundle['Scripts']),
'Names' => array_diff_key(iterator_to_array($localeBundle['Scripts']), self::$blacklist),
];

$this->scriptCodes = array_merge($this->scriptCodes, array_keys($data['Names']));
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Intl/Resources/data/regions/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@
"VU": "فانواتو",
"WF": "جزر والس وفوتونا",
"WS": "ساموا",
"XA": "XA",
"XK": "كوسوفو",
"YE": "اليمن",
"YT": "مايوت",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/as.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "ভানাটু",
"WF": "ৱালিছ আৰু ফুটুনা",
"WS": "চামোৱা",
"XA": "ছুডু-একচেণ্ট",
"XB": "ছুডু-বিডি",
"XK": "কচ’ভ’",
"YE": "য়েমেন",
"YT": "মায়োট্টে",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Uollis və Futuna",
"WS": "Samoa",
"XA": "Psevdo-Aksent",
"XB": "Psevdo-Bidi",
"XK": "Kosovo",
"YE": "Yəmən",
"YT": "Mayot",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis i Futuna",
"WS": "Samoa",
"XA": "Pseudo-Accents",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Iemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis a Futuna",
"WS": "Samoa",
"XA": "simulovaná diakritika",
"XB": "simulovaný obousměrný zápis",
"XK": "Kosovo",
"YE": "Jemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis a Futuna",
"WS": "Samoa",
"XA": "Acenion Ffug",
"XB": "Bidi Ffug",
"XK": "Kosovo",
"YE": "Yemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Βανουάτου",
"WF": "Γουάλις και Φουτούνα",
"WS": "Σαμόα",
"XA": "Ψευδο-προφορές",
"XB": "Ψευδο-αμφικατευθυντικό",
"XK": "Κοσσυφοπέδιο",
"YE": "Υεμένη",
"YT": "Μαγιότ",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis & Futuna",
"WS": "Samoa",
"XA": "Pseudo-Accents",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Yemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis ja Futuna",
"WS": "Samoa",
"XA": "pseudo-aktsent",
"XB": "pseudo-Bidi",
"XK": "Kosovo",
"YE": "Jeemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis-et-Futuna",
"WS": "Samoa",
"XA": "pseudo-accents",
"XB": "pseudo-bidi",
"XK": "Kosovo",
"YE": "Yémen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/ga.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatú",
"WF": "Vailís agus Futúna",
"WS": "Samó",
"XA": "XA",
"XB": "XB",
"XK": "an Chosaiv",
"YE": "Éimin",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/hr.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis i Futuna",
"WS": "Samoa",
"XA": "pseudo naglasci",
"XB": "pseudo bidi",
"XK": "Kosovo",
"YE": "Jemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis és Futuna",
"WS": "Szamoa",
"XA": "Pszeudo-nyelvjárások",
"XB": "Pszeudo-kétirányú",
"XK": "Koszovó",
"YE": "Jemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Kepulauan Wallis dan Futuna",
"WS": "Samoa",
"XA": "Aksen Asing",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Yaman",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/in.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Kepulauan Wallis dan Futuna",
"WS": "Samoa",
"XA": "Aksen Asing",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Yaman",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis e Futuna",
"WS": "Samoa",
"XA": "pseudo-accenti",
"XB": "pseudo-bidi",
"XK": "Kosovo",
"YE": "Yemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/kk.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Вануату",
"WF": "Уоллис және Футуна",
"WS": "Самоа",
"XA": "жалған акцент",
"XB": "жалған Bidi",
"XK": "Косово",
"YE": "Йемен",
"YT": "Майотта",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "바누아투",
"WF": "왈리스-푸투나 제도",
"WS": "사모아",
"XA": "유사 억양",
"XB": "유사 양방향",
"XK": "코소보",
"YE": "예멘",
"YT": "마요트",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Volisas ir Futūna",
"WS": "Samoa",
"XA": "XA",
"XB": "XB",
"XK": "Kosovas",
"YE": "Jemenas",
"YT": "Majotas",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Volisa un Futunas salas",
"WS": "Samoa",
"XA": "pseidoakcenti",
"XB": "pseido-Bidi",
"XK": "Kosova",
"YE": "Jemena",
"YT": "Majota",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU",
"WF",
"WS",
"XA",
"XB",
"XK",
"YE",
"YT",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/mk.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Вануату",
"WF": "Валис и Футуна",
"WS": "Самоа",
"XA": "псевдо-акценти",
"XB": "псевдо-биди",
"XK": "Косово",
"YE": "Јемен",
"YT": "Мајот",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/mo.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis și Futuna",
"WS": "Samoa",
"XA": "Pseudo-accente",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Yemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis dan Futuna",
"WS": "Samoa",
"XA": "XA",
"XB": "XB",
"XK": "Kosovo",
"YE": "Yaman",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis en Futuna",
"WS": "Samoa",
"XA": "Pseudo-Accenten",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Jemen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "ଭାନୁଆତୁ",
"WF": "ୱାଲିସ୍ ଏବଂ ଫୁତୁନା",
"WS": "ସାମୋଆ",
"XA": "ସିୟୁଡୋ-ଏସେଣ୍ଟ",
"XB": "ସିୟୁଡୋ-ବିଡି",
"XK": "କୋସୋଭୋ",
"YE": "ୟେମେନ୍",
"YT": "ମାୟୋଟେ",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis i Futuna",
"WS": "Samoa",
"XA": "Pseudoakcenty",
"XB": "Pseudodwukierunkowe",
"XK": "Kosowo",
"YE": "Jemen",
"YT": "Majotta",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/ps.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "واناتو",
"WF": "والیس او فوتونا",
"WS": "ساموا",
"XA": "جعلي خج",
"XB": "جعلي بيدي",
"XK": "کوسوو",
"YE": "یمن",
"YT": "مايوټ",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis e Futuna",
"WS": "Samoa",
"XA": "Pseudossotaques",
"XB": "Pseudobidi",
"XK": "Kosovo",
"YE": "Iêmen",
"YT": "Mayotte",
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Component/Intl/Resources/data/regions/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@
"VU": "Vanuatu",
"WF": "Wallis și Futuna",
"WS": "Samoa",
"XA": "Pseudo-accente",
"XB": "Pseudo-Bidi",
"XK": "Kosovo",
"YE": "Yemen",
"YT": "Mayotte",
Expand Down
Loading

0 comments on commit 5b24cb6

Please sign in to comment.