Skip to content
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

[Intl] Order alpha2 to alpha3 mapping + phpdoc fixes #32919

Merged
merged 1 commit into from Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Symfony/Component/Intl/Countries.php
Expand Up @@ -31,13 +31,16 @@ final class Countries extends ResourceBundle
*
* This list only contains "officially assigned ISO 3166-1 alpha-2" country codes.
*
* @return string[] an array of canonical ISO 3166 country codes
* @return string[] an array of canonical ISO 3166 alpha-2 country codes
*/
public static function getCountryCodes(): array
{
return self::readEntry(['Regions'], 'meta');
}

/**
* @param string $country Alpha2 country code
*/
public static function exists(string $country): bool
{
try {
Expand All @@ -50,6 +53,8 @@ public static function exists(string $country): bool
}

/**
* Get country name from alpha2 code.
*
* @throws MissingResourceException if the country code does not exists
*/
public static function getName(string $country, string $displayLocale = null): string
Expand All @@ -58,9 +63,11 @@ public static function getName(string $country, string $displayLocale = null): s
}

/**
* Get list of country names indexed with alpha2 codes as keys.
*
* @return string[]
*/
public static function getNames($displayLocale = null)
public static function getNames($displayLocale = null): array
{
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
}
Expand Down
Expand Up @@ -204,6 +204,8 @@ private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $me
}
}

asort($alpha2ToAlpha3);

return $alpha2ToAlpha3;
}
}
10 changes: 7 additions & 3 deletions src/Symfony/Component/Intl/Languages.php
Expand Up @@ -22,7 +22,7 @@
final class Languages extends ResourceBundle
{
/**
* Returns all available languages.
* Returns all available languages as two-letter codes.
*
* Languages are returned as lowercase ISO 639-1 two-letter language codes.
* For languages that don't have a two-letter code, the ISO 639-2
Expand All @@ -31,7 +31,7 @@ final class Languages extends ResourceBundle
* A full table of ISO 639 language codes can be found here:
* http://www-01.sil.org/iso639-3/codes.asp
*
* @return string[] an array of canonical ISO 639 language codes
* @return string[] an array of canonical ISO 639-1 language codes
*/
public static function getLanguageCodes(): array
{
Expand All @@ -50,6 +50,8 @@ public static function exists(string $language): bool
}

/**
* Get language name from alpha2 code.
*
* @throws MissingResourceException if the language code does not exists
*/
public static function getName(string $language, string $displayLocale = null): string
Expand All @@ -58,6 +60,8 @@ public static function getName(string $language, string $displayLocale = null):
}

/**
* Get list of language names indexed with alpha2 codes as keys.
*
* @return string[]
*/
public static function getNames(string $displayLocale = null): array
Expand All @@ -66,7 +70,7 @@ public static function getNames(string $displayLocale = null): array
}

/**
* Returns the ISO 639-2 three-letter code of a language.
* Returns the ISO 639-2 three-letter code of a language, given a two-letter code.
*
* @throws MissingResourceException if the language has no corresponding three-letter code
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Intl/Locales.php
Expand Up @@ -67,7 +67,7 @@ public static function getName(string $locale, string $displayLocale = null): st
/**
* @return string[]
*/
public static function getNames($displayLocale = null)
public static function getNames($displayLocale = null): array
{
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
}
Expand Down
42 changes: 21 additions & 21 deletions src/Symfony/Component/Intl/Resources/data/languages/meta.json
Expand Up @@ -623,35 +623,29 @@
"Alpha2ToAlpha3": {
"aa": "aar",
"ab": "abk",
"dz": "dzo",
"af": "afr",
"ak": "aka",
"sq": "sqi",
"am": "amh",
"ar": "ara",
"an": "arg",
"hy": "hye",
"as": "asm",
"av": "ava",
"ae": "ave",
"ay": "aym",
"az": "aze",
"ba": "bak",
"bm": "bam",
"eu": "eus",
"be": "bel",
"bn": "ben",
"bi": "bis",
"bo": "bod",
"bs": "bos",
"br": "bre",
"bg": "bul",
"my": "mya",
"ca": "cat",
"cs": "ces",
"ch": "cha",
"ce": "che",
"zh": "zho",
"cu": "chu",
"cv": "chv",
"kw": "cor",
Expand All @@ -661,13 +655,12 @@
"da": "dan",
"de": "deu",
"dv": "div",
"mn": "mon",
"nl": "nld",
"et": "est",
"dz": "dzo",
"el": "ell",
"en": "eng",
"eo": "epo",
"ik": "ipk",
"et": "est",
"eu": "eus",
"ee": "ewe",
"fo": "fao",
"fa": "fas",
Expand All @@ -676,8 +669,6 @@
"fr": "fra",
"fy": "fry",
"ff": "ful",
"om": "orm",
"ka": "kat",
"gd": "gla",
"ga": "gle",
"gl": "glg",
Expand All @@ -692,31 +683,34 @@
"ho": "hmo",
"hr": "hrv",
"hu": "hun",
"hy": "hye",
"ig": "ibo",
"is": "isl",
"io": "ido",
"ii": "iii",
"iu": "iku",
"ie": "ile",
"ia": "ina",
"id": "ind",
"ik": "ipk",
"is": "isl",
"it": "ita",
"jv": "jav",
"ja": "jpn",
"kl": "kal",
"kn": "kan",
"ks": "kas",
"ka": "kat",
"kr": "kau",
"kk": "kaz",
"km": "khm",
"ki": "kik",
"rw": "kin",
"ky": "kir",
"ku": "kur",
"kg": "kon",
"kv": "kom",
"kg": "kon",
"ko": "kor",
"kj": "kua",
"ku": "kur",
"lo": "lao",
"la": "lat",
"lv": "lav",
Expand All @@ -726,40 +720,43 @@
"lb": "ltz",
"lu": "lub",
"lg": "lug",
"mk": "mkd",
"mh": "mah",
"ml": "mal",
"mi": "mri",
"mr": "mar",
"ms": "msa",
"mk": "mkd",
"mg": "mlg",
"mt": "mlt",
"ro": "ron",
"mn": "mon",
"mi": "mri",
"ms": "msa",
"my": "mya",
"na": "nau",
"nv": "nav",
"nr": "nbl",
"nd": "nde",
"ng": "ndo",
"ne": "nep",
"nl": "nld",
"nn": "nno",
"nb": "nob",
"ny": "nya",
"oc": "oci",
"oj": "oji",
"or": "ori",
"om": "orm",
"os": "oss",
"pa": "pan",
"ps": "pus",
"pi": "pli",
"pl": "pol",
"pt": "por",
"ps": "pus",
"qu": "que",
"rm": "roh",
"ro": "ron",
"rn": "run",
"ru": "rus",
"sg": "sag",
"sa": "san",
"sr": "srp",
"si": "sin",
"sk": "slk",
"sl": "slv",
Expand All @@ -770,7 +767,9 @@
"so": "som",
"st": "sot",
"es": "spa",
"sq": "sqi",
"sc": "srd",
"sr": "srp",
"ss": "ssw",
"su": "sun",
"sw": "swa",
Expand Down Expand Up @@ -800,6 +799,7 @@
"yi": "yid",
"yo": "yor",
"za": "zha",
"zh": "zho",
"zu": "zul"
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Intl/Scripts.php
Expand Up @@ -51,7 +51,7 @@ public static function getName(string $script, string $displayLocale = null): st
/**
* @return string[]
*/
public static function getNames($displayLocale = null)
public static function getNames($displayLocale = null): array
{
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
}
Expand Down