Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 867e3de

Browse files
committed
[Intl] Order alpha2 to alpha3 mapping + phpdoc fixes
1 parent 69ef436 commit 867e3de

File tree

8 files changed

+79
-66
lines changed

8 files changed

+79
-66
lines changed

src/Symfony/Component/Intl/Countries.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ final class Countries extends ResourceBundle
3131
*
3232
* This list only contains "officially assigned ISO 3166-1 alpha-2" country codes.
3333
*
34-
* @return string[] an array of canonical ISO 3166 country codes
34+
* @return string[] an array of canonical ISO 3166 alpha-2 country codes
3535
*/
3636
public static function getCountryCodes(): array
3737
{
3838
return self::readEntry(['Regions'], 'meta');
3939
}
4040

41+
/**
42+
* @param string $country Alpha2 country code
43+
*/
4144
public static function exists(string $country): bool
4245
{
4346
try {
@@ -50,6 +53,8 @@ public static function exists(string $country): bool
5053
}
5154

5255
/**
56+
* Get country name from alpha2 code.
57+
*
5358
* @throws MissingResourceException if the country code does not exists
5459
*/
5560
public static function getName(string $country, string $displayLocale = null): string
@@ -58,9 +63,11 @@ public static function getName(string $country, string $displayLocale = null): s
5863
}
5964

6065
/**
66+
* Get list of country names indexed with alpha2 codes as keys.
67+
*
6168
* @return string[]
6269
*/
63-
public static function getNames($displayLocale = null)
70+
public static function getNames($displayLocale = null): array
6471
{
6572
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
6673
}

src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $me
204204
}
205205
}
206206

207+
asort($alpha2ToAlpha3);
208+
207209
return $alpha2ToAlpha3;
208210
}
209211
}

src/Symfony/Component/Intl/Languages.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
final class Languages extends ResourceBundle
2323
{
2424
/**
25-
* Returns all available languages.
25+
* Returns all available languages as two-letter codes.
2626
*
2727
* Languages are returned as lowercase ISO 639-1 two-letter language codes.
2828
* For languages that don't have a two-letter code, the ISO 639-2
@@ -31,7 +31,7 @@ final class Languages extends ResourceBundle
3131
* A full table of ISO 639 language codes can be found here:
3232
* http://www-01.sil.org/iso639-3/codes.asp
3333
*
34-
* @return string[] an array of canonical ISO 639 language codes
34+
* @return string[] an array of canonical ISO 639-1 language codes
3535
*/
3636
public static function getLanguageCodes(): array
3737
{
@@ -50,6 +50,8 @@ public static function exists(string $language): bool
5050
}
5151

5252
/**
53+
* Get language name from alpha2 code.
54+
*
5355
* @throws MissingResourceException if the language code does not exists
5456
*/
5557
public static function getName(string $language, string $displayLocale = null): string
@@ -58,6 +60,8 @@ public static function getName(string $language, string $displayLocale = null):
5860
}
5961

6062
/**
63+
* Get list of language names indexed with alpha2 codes as keys.
64+
*
6165
* @return string[]
6266
*/
6367
public static function getNames(string $displayLocale = null): array
@@ -66,7 +70,7 @@ public static function getNames(string $displayLocale = null): array
6670
}
6771

6872
/**
69-
* Returns the ISO 639-2 three-letter code of a language.
73+
* Returns the ISO 639-2 three-letter code of a language, given a two-letter code.
7074
*
7175
* @throws MissingResourceException if the language has no corresponding three-letter code
7276
*/

src/Symfony/Component/Intl/Locales.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function getName(string $locale, string $displayLocale = null): st
6767
/**
6868
* @return string[]
6969
*/
70-
public static function getNames($displayLocale = null)
70+
public static function getNames($displayLocale = null): array
7171
{
7272
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
7373
}

src/Symfony/Component/Intl/Resources/data/languages/meta.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -623,35 +623,29 @@
623623
"Alpha2ToAlpha3": {
624624
"aa": "aar",
625625
"ab": "abk",
626-
"dz": "dzo",
627626
"af": "afr",
628627
"ak": "aka",
629-
"sq": "sqi",
630628
"am": "amh",
631629
"ar": "ara",
632630
"an": "arg",
633-
"hy": "hye",
634631
"as": "asm",
635632
"av": "ava",
636633
"ae": "ave",
637634
"ay": "aym",
638635
"az": "aze",
639636
"ba": "bak",
640637
"bm": "bam",
641-
"eu": "eus",
642638
"be": "bel",
643639
"bn": "ben",
644640
"bi": "bis",
645641
"bo": "bod",
646642
"bs": "bos",
647643
"br": "bre",
648644
"bg": "bul",
649-
"my": "mya",
650645
"ca": "cat",
651646
"cs": "ces",
652647
"ch": "cha",
653648
"ce": "che",
654-
"zh": "zho",
655649
"cu": "chu",
656650
"cv": "chv",
657651
"kw": "cor",
@@ -661,13 +655,12 @@
661655
"da": "dan",
662656
"de": "deu",
663657
"dv": "div",
664-
"mn": "mon",
665-
"nl": "nld",
666-
"et": "est",
658+
"dz": "dzo",
667659
"el": "ell",
668660
"en": "eng",
669661
"eo": "epo",
670-
"ik": "ipk",
662+
"et": "est",
663+
"eu": "eus",
671664
"ee": "ewe",
672665
"fo": "fao",
673666
"fa": "fas",
@@ -676,8 +669,6 @@
676669
"fr": "fra",
677670
"fy": "fry",
678671
"ff": "ful",
679-
"om": "orm",
680-
"ka": "kat",
681672
"gd": "gla",
682673
"ga": "gle",
683674
"gl": "glg",
@@ -692,31 +683,34 @@
692683
"ho": "hmo",
693684
"hr": "hrv",
694685
"hu": "hun",
686+
"hy": "hye",
695687
"ig": "ibo",
696-
"is": "isl",
697688
"io": "ido",
698689
"ii": "iii",
699690
"iu": "iku",
700691
"ie": "ile",
701692
"ia": "ina",
702693
"id": "ind",
694+
"ik": "ipk",
695+
"is": "isl",
703696
"it": "ita",
704697
"jv": "jav",
705698
"ja": "jpn",
706699
"kl": "kal",
707700
"kn": "kan",
708701
"ks": "kas",
702+
"ka": "kat",
709703
"kr": "kau",
710704
"kk": "kaz",
711705
"km": "khm",
712706
"ki": "kik",
713707
"rw": "kin",
714708
"ky": "kir",
715-
"ku": "kur",
716-
"kg": "kon",
717709
"kv": "kom",
710+
"kg": "kon",
718711
"ko": "kor",
719712
"kj": "kua",
713+
"ku": "kur",
720714
"lo": "lao",
721715
"la": "lat",
722716
"lv": "lav",
@@ -726,40 +720,43 @@
726720
"lb": "ltz",
727721
"lu": "lub",
728722
"lg": "lug",
729-
"mk": "mkd",
730723
"mh": "mah",
731724
"ml": "mal",
732-
"mi": "mri",
733725
"mr": "mar",
734-
"ms": "msa",
726+
"mk": "mkd",
735727
"mg": "mlg",
736728
"mt": "mlt",
737-
"ro": "ron",
729+
"mn": "mon",
730+
"mi": "mri",
731+
"ms": "msa",
732+
"my": "mya",
738733
"na": "nau",
739734
"nv": "nav",
740735
"nr": "nbl",
741736
"nd": "nde",
742737
"ng": "ndo",
743738
"ne": "nep",
739+
"nl": "nld",
744740
"nn": "nno",
745741
"nb": "nob",
746742
"ny": "nya",
747743
"oc": "oci",
748744
"oj": "oji",
749745
"or": "ori",
746+
"om": "orm",
750747
"os": "oss",
751748
"pa": "pan",
752-
"ps": "pus",
753749
"pi": "pli",
754750
"pl": "pol",
755751
"pt": "por",
752+
"ps": "pus",
756753
"qu": "que",
757754
"rm": "roh",
755+
"ro": "ron",
758756
"rn": "run",
759757
"ru": "rus",
760758
"sg": "sag",
761759
"sa": "san",
762-
"sr": "srp",
763760
"si": "sin",
764761
"sk": "slk",
765762
"sl": "slv",
@@ -770,7 +767,9 @@
770767
"so": "som",
771768
"st": "sot",
772769
"es": "spa",
770+
"sq": "sqi",
773771
"sc": "srd",
772+
"sr": "srp",
774773
"ss": "ssw",
775774
"su": "sun",
776775
"sw": "swa",
@@ -800,6 +799,7 @@
800799
"yi": "yid",
801800
"yo": "yor",
802801
"za": "zha",
802+
"zh": "zho",
803803
"zu": "zul"
804804
}
805805
}

src/Symfony/Component/Intl/Scripts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function getName(string $script, string $displayLocale = null): st
5151
/**
5252
* @return string[]
5353
*/
54-
public static function getNames($displayLocale = null)
54+
public static function getNames($displayLocale = null): array
5555
{
5656
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
5757
}

0 commit comments

Comments
 (0)