Skip to content

[Intl] Excludes locale from language codes (split localized language names) #33148

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

Merged
merged 1 commit into from
Sep 27, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Component/Intl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

* excluded language code `root`
* added to both `Countries` and `Languages` the methods `getAlpha3Codes`, `getAlpha3Code`, `getAlpha2Code`, `alpha3CodeExists`, `getAlpha3Name` and `getAlpha3Names`
* excluded localized languages (e.g. `en_US`) from `Languages` in `getLanguageCodes()` and `getNames()`

4.3.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,22 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str

// isset() on \ResourceBundle returns true even if the value is null
if (isset($localeBundle['Languages']) && null !== $localeBundle['Languages']) {
$names = [];
$localizedNames = [];
foreach (self::generateLanguageNames($localeBundle) as $language => $name) {
if (false === strpos($language, '_')) {
$this->languageCodes[] = $language;
$names[$language] = $name;
} else {
$localizedNames[$language] = $name;
}
}
$data = [
'Version' => $localeBundle['Version'],
'Names' => self::generateLanguageNames($localeBundle),
'Names' => $names,
'LocalizedNames' => $localizedNames,
];

$this->languageCodes = array_merge($this->languageCodes, array_keys($data['Names']));

return $data;
}

Expand Down
16 changes: 15 additions & 1 deletion src/Symfony/Component/Intl/Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,25 @@ public static function exists(string $language): bool
/**
* Gets the language name from its alpha2 code.
*
* A full locale may be passed to obtain a more localized language name, e.g. "American English" for "en_US".
*
* @throws MissingResourceException if the language code does not exist
*/
public static function getName(string $language, string $displayLocale = null): string
{
return self::readEntry(['Names', $language], $displayLocale);
try {
return self::readEntry(['Names', $language], $displayLocale);
} catch (MissingResourceException $e) {
try {
return self::readEntry(['LocalizedNames', $language], $displayLocale);
} catch (MissingResourceException $e) {
if (false !== $i = strrpos($language, '_')) {
return self::getName(substr($language, 0, $i), $displayLocale);
}

throw $e;
}
}
}

/**
Expand Down
18 changes: 10 additions & 8 deletions src/Symfony/Component/Intl/Resources/data/languages/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"an": "Aragonees",
"anp": "Angika",
"ar": "Arabies",
"ar_001": "Moderne Standaardarabies",
"arc": "Aramees",
"arn": "Mapuche",
"arp": "Arapaho",
Expand Down Expand Up @@ -71,7 +70,6 @@
"dar": "Dakota",
"dav": "Taita",
"de": "Duits",
"de_CH": "Switserse hoog-Duits",
"dgr": "Dogrib",
"dje": "Zarma",
"dsb": "Benedesorbies",
Expand All @@ -87,8 +85,6 @@
"eka": "Ekajuk",
"el": "Grieks",
"en": "Engels",
"en_GB": "Engels (VK)",
"en_US": "Engels (VSA)",
"eo": "Esperanto",
"es": "Spaans",
"et": "Estnies",
Expand Down Expand Up @@ -252,14 +248,12 @@
"nb": "Boeknoors",
"nd": "Noord-Ndebele",
"nds": "Lae Duits",
"nds_NL": "Nedersaksies",
"ne": "Nepalees",
"new": "Newari",
"ng": "Ndonga",
"nia": "Nias",
"niu": "Niueaans",
"nl": "Nederlands",
"nl_BE": "Vlaams",
"nmg": "Kwasio",
"nn": "Nuwe Noors",
"nnh": "Ngiemboon",
Expand Down Expand Up @@ -394,10 +388,18 @@
"yue": "Kantonees",
"zgh": "Standaard Marokkaanse Tamazight",
"zh": "Sjinees",
"zh_Hans": "Chinees (Vereenvoudig)",
"zh_Hant": "Chinees (Tradisioneel)",
"zu": "Zoeloe",
"zun": "Zuni",
"zza": "Zaza"
},
"LocalizedNames": {
"ar_001": "Moderne Standaardarabies",
"de_CH": "Switserse hoog-Duits",
"en_GB": "Engels (VK)",
"en_US": "Engels (VSA)",
"nds_NL": "Nedersaksies",
"nl_BE": "Vlaams",
"zh_Hans": "Chinees (Vereenvoudig)",
"zh_Hant": "Chinees (Tradisioneel)"
}
}
3 changes: 2 additions & 1 deletion src/Symfony/Component/Intl/Resources/data/languages/ak.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
"yo": "Yoruba",
"zh": "Kyaena kasa",
"zu": "Zulu"
}
},
"LocalizedNames": []
}
42 changes: 22 additions & 20 deletions src/Symfony/Component/Intl/Resources/data/languages/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"an": "አራጎንስ",
"anp": "አንጊካ",
"ar": "ዓረብኛ",
"ar_001": "ዘመናዊ መደበኛ ዓረብኛ",
"arc": "አራማይክ",
"arn": "ማፑቼ",
"aro": "አራኦና",
Expand Down Expand Up @@ -107,8 +106,6 @@
"dar": "ዳርግዋ",
"dav": "ታይታኛ",
"de": "ጀርመን",
"de_AT": "የኦስትሪያ ጀርመን",
"de_CH": "የስዊዝ ከፍተኛ ጀርመንኛ",
"del": "ዳላዌር",
"dgr": "ዶግሪብ",
"din": "ዲንካ",
Expand All @@ -129,15 +126,8 @@
"eka": "ኤካጁክ",
"el": "ግሪክኛ",
"en": "እንግሊዝኛ",
"en_AU": "የአውስትራሊያ እንግሊዝኛ",
"en_CA": "የካናዳ እንግሊዝኛ",
"en_GB": "የብሪቲሽ እንግሊዝኛ",
"en_US": "የአሜሪካ እንግሊዝኛ",
"eo": "ኤስፐራንቶ",
"es": "ስፓንሽኛ",
"es_419": "የላቲን አሜሪካ ስፓኒሽ",
"es_ES": "የአውሮፓ ስፓንሽኛ",
"es_MX": "የሜክሲኮ ስፓንሽኛ",
"esu": "ሴንተራል ዩፒክ",
"et": "ኢስቶኒያንኛ",
"eu": "ባስክኛ",
Expand All @@ -150,8 +140,6 @@
"fo": "ፋሮኛ",
"fon": "ፎን",
"fr": "ፈረንሳይኛ",
"fr_CA": "የካናዳ ፈረንሳይኛ",
"fr_CH": "የስዊዝ ፈረንሳይኛ",
"frc": "ካጁን ፍሬንች",
"frp": "አርፒታን",
"fur": "ፍሩሊያን",
Expand Down Expand Up @@ -303,15 +291,13 @@
"nb": "የኖርዌይ ቦክማል",
"nd": "ሰሜን ንዴብሌ",
"nds": "የታችኛው ጀርመን",
"nds_NL": "የታችኛው ሳክሰን",
"ne": "ኔፓሊኛ",
"new": "ኒዋሪ(ኔፓል)",
"ng": "ንዶንጋ",
"nia": "ኒአስ",
"niu": "ኒዩአንኛ",
"njo": "ኦ ናጋ",
"nl": "ደች",
"nl_BE": "ፍሌሚሽ",
"nmg": "ክዋሲዮ",
"nn": "የኖርዌይ ናይኖርስክ",
"nnh": "ኒጊምቡን",
Expand Down Expand Up @@ -339,8 +325,6 @@
"prg": "ፐሩሳንኛ",
"ps": "ፓሽቶኛ",
"pt": "ፖርቹጋልኛ",
"pt_BR": "የብራዚል ፖርቹጋልኛ",
"pt_PT": "የአውሮፓ ፖርቹጋልኛ",
"qu": "ኵቿኛ",
"quc": "ኪቼ",
"qug": "ቺምቦራዞ ሃይላንድ ኩቹዋ",
Expand All @@ -349,7 +333,6 @@
"rm": "ሮማንሽ",
"rn": "ሩንዲኛ",
"ro": "ሮማኒያን",
"ro_MD": "ሞልዳቪያንኛ",
"rof": "ሮምቦ",
"ru": "ራሽያኛ",
"rup": "አሮማንያን",
Expand Down Expand Up @@ -397,7 +380,6 @@
"suk": "ሱኩማ",
"sv": "ስዊድንኛ",
"sw": "ስዋሂሊኛ",
"sw_CD": "ኮንጎ ስዋሂሊ",
"swb": "ኮሞሪያን",
"syc": "ክላሲክ ኔይራ",
"syr": "ሲሪያክ",
Expand Down Expand Up @@ -457,10 +439,30 @@
"zbl": "ብሊስይምቦልስ",
"zgh": "መደበኛ የሞሮኮ ታማዚግት",
"zh": "ቻይንኛ",
"zh_Hans": "ቀለል ያለ ቻይንኛ",
"zh_Hant": "ባህላዊ ቻይንኛ",
"zu": "ዙሉኛ",
"zun": "ዙኒ",
"zza": "ዛዛ"
},
"LocalizedNames": {
"ar_001": "ዘመናዊ መደበኛ ዓረብኛ",
"de_AT": "የኦስትሪያ ጀርመን",
"de_CH": "የስዊዝ ከፍተኛ ጀርመንኛ",
"en_AU": "የአውስትራሊያ እንግሊዝኛ",
"en_CA": "የካናዳ እንግሊዝኛ",
"en_GB": "የብሪቲሽ እንግሊዝኛ",
"en_US": "የአሜሪካ እንግሊዝኛ",
"es_419": "የላቲን አሜሪካ ስፓኒሽ",
"es_ES": "የአውሮፓ ስፓንሽኛ",
"es_MX": "የሜክሲኮ ስፓንሽኛ",
"fr_CA": "የካናዳ ፈረንሳይኛ",
"fr_CH": "የስዊዝ ፈረንሳይኛ",
"nds_NL": "የታችኛው ሳክሰን",
"nl_BE": "ፍሌሚሽ",
"pt_BR": "የብራዚል ፖርቹጋልኛ",
"pt_PT": "የአውሮፓ ፖርቹጋልኛ",
"ro_MD": "ሞልዳቪያንኛ",
"sw_CD": "ኮንጎ ስዋሂሊ",
"zh_Hans": "ቀለል ያለ ቻይንኛ",
"zh_Hant": "ባህላዊ ቻይንኛ"
}
}
42 changes: 22 additions & 20 deletions src/Symfony/Component/Intl/Resources/data/languages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"ang": "الإنجليزية القديمة",
"anp": "الأنجيكا",
"ar": "العربية",
"ar_001": "العربية الرسمية الحديثة",
"arc": "الآرامية",
"arn": "المابودونغونية",
"arp": "الأراباهو",
Expand Down Expand Up @@ -100,8 +99,6 @@
"dar": "الدارجوا",
"dav": "تيتا",
"de": "الألمانية",
"de_AT": "الألمانية النمساوية",
"de_CH": "الألمانية العليا السويسرية",
"del": "الديلوير",
"den": "السلافية",
"dgr": "الدوجريب",
Expand All @@ -124,16 +121,9 @@
"el": "اليونانية",
"elx": "الإمايت",
"en": "الإنجليزية",
"en_AU": "الإنجليزية الأسترالية",
"en_CA": "الإنجليزية الكندية",
"en_GB": "الإنجليزية البريطانية",
"en_US": "الإنجليزية الأمريكية",
"enm": "الإنجليزية الوسطى",
"eo": "الإسبرانتو",
"es": "الإسبانية",
"es_419": "الإسبانية أمريكا اللاتينية",
"es_ES": "الإسبانية الأوروبية",
"es_MX": "الإسبانية المكسيكية",
"et": "الإستونية",
"eu": "الباسكية",
"ewo": "الإيوندو",
Expand All @@ -147,8 +137,6 @@
"fo": "الفاروية",
"fon": "الفون",
"fr": "الفرنسية",
"fr_CA": "الفرنسية الكندية",
"fr_CH": "الفرنسية السويسرية",
"frc": "الفرنسية الكاجونية",
"frm": "الفرنسية الوسطى",
"fro": "الفرنسية القديمة",
Expand Down Expand Up @@ -332,14 +320,12 @@
"nb": "النرويجية بوكمال",
"nd": "النديبيل الشمالية",
"nds": "الألمانية السفلى",
"nds_NL": "السكسونية السفلى",
"ne": "النيبالية",
"new": "النوارية",
"ng": "الندونجا",
"nia": "النياس",
"niu": "النيوي",
"nl": "الهولندية",
"nl_BE": "الفلمنكية",
"nmg": "كواسيو",
"nn": "النرويجية نينورسك",
"nnh": "لغة النجيمبون",
Expand Down Expand Up @@ -380,8 +366,6 @@
"pro": "البروفانسية القديمة",
"ps": "البشتو",
"pt": "البرتغالية",
"pt_BR": "البرتغالية البرازيلية",
"pt_PT": "البرتغالية الأوروبية",
"qu": "الكويتشوا",
"quc": "الكيشية",
"raj": "الراجاسثانية",
Expand All @@ -390,7 +374,6 @@
"rm": "الرومانشية",
"rn": "الرندي",
"ro": "الرومانية",
"ro_MD": "المولدوفية",
"rof": "الرومبو",
"rom": "الغجرية",
"ru": "الروسية",
Expand Down Expand Up @@ -448,7 +431,6 @@
"sux": "السومارية",
"sv": "السويدية",
"sw": "السواحلية",
"sw_CD": "الكونغو السواحلية",
"swb": "القمرية",
"syc": "سريانية تقليدية",
"syr": "السريانية",
Expand Down Expand Up @@ -522,10 +504,30 @@
"zen": "الزيناجا",
"zgh": "التمازيغية المغربية القياسية",
"zh": "الصينية",
"zh_Hans": "الصينية المبسطة",
"zh_Hant": "الصينية التقليدية",
"zu": "الزولو",
"zun": "الزونية",
"zza": "زازا"
},
"LocalizedNames": {
"ar_001": "العربية الرسمية الحديثة",
"de_AT": "الألمانية النمساوية",
"de_CH": "الألمانية العليا السويسرية",
"en_AU": "الإنجليزية الأسترالية",
"en_CA": "الإنجليزية الكندية",
"en_GB": "الإنجليزية البريطانية",
"en_US": "الإنجليزية الأمريكية",
"es_419": "الإسبانية أمريكا اللاتينية",
"es_ES": "الإسبانية الأوروبية",
"es_MX": "الإسبانية المكسيكية",
"fr_CA": "الفرنسية الكندية",
"fr_CH": "الفرنسية السويسرية",
"nds_NL": "السكسونية السفلى",
"nl_BE": "الفلمنكية",
"pt_BR": "البرتغالية البرازيلية",
"pt_PT": "البرتغالية الأوروبية",
"ro_MD": "المولدوفية",
"sw_CD": "الكونغو السواحلية",
"zh_Hans": "الصينية المبسطة",
"zh_Hant": "الصينية التقليدية"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"Version": "2.1.49.36",
"Names": {
"da": "الدنماركية"
}
},
"LocalizedNames": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"sh": "الكرواتية الصربية",
"sma": "سامي الجنوبية",
"sw": "السواحيلية",
"sw_CD": "السواحيلية الكونغولية",
"ti": "التيغرينية"
},
"LocalizedNames": {
"sw_CD": "السواحيلية الكونغولية"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"sh": "الكرواتية الصربية",
"sma": "سامي الجنوبية",
"sw": "السواحيلية",
"sw_CD": "السواحيلية الكونغولية",
"te": "التيلوجو",
"ti": "التيغرينية"
},
"LocalizedNames": {
"sw_CD": "السواحيلية الكونغولية"
}
}
Loading