Skip to content

Commit 67d306e

Browse files
Merge branch '4.4'
* 4.4: [Form][Validator][Intl] Fix tests [Messenger] return empty envelopes when RetryableException occurs [Intl] Excludes locale from language codes (split localized language names) [FrameworkBundle] WebTestCase KernelBrowser::getContainer null return type [Intl] Fix compile type errors [Validator] Accept underscores in the URL validator as the URL will resolve correctly [Translation] Collect original locale in case of fallback translation Add types to constructors and private/final/internal methods (Batch I) [HttpFoundation] optimize normalization of headers Replace REMOTE_ADDR in trusted proxies with the current REMOTE_ADDR [ErrorHandler] Forward \Throwable Fix toolbar load when GET params are present in "_wdt" route
2 parents 69c7436 + 101025d commit 67d306e

File tree

208 files changed

+2373
-2030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+2373
-2030
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CHANGELOG
1111

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

1516
4.3.0
1617
-----

Data/Generator/FallbackTrait.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,14 @@ trait FallbackTrait
2525
private $generatingFallback = false;
2626

2727
/**
28-
* @return array|null
29-
*
3028
* @see AbstractDataGenerator::generateDataForLocale()
3129
*/
32-
abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale);
30+
abstract protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array;
3331

3432
/**
35-
* @return array|null
36-
*
3733
* @see AbstractDataGenerator::generateDataForRoot()
3834
*/
39-
abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir);
35+
abstract protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array;
4036

4137
private function generateFallbackData(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): array
4238
{

Data/Generator/LanguageDataGenerator.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,22 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
132132

133133
// isset() on \ResourceBundle returns true even if the value is null
134134
if (isset($localeBundle['Languages']) && null !== $localeBundle['Languages']) {
135+
$names = [];
136+
$localizedNames = [];
137+
foreach (self::generateLanguageNames($localeBundle) as $language => $name) {
138+
if (false === strpos($language, '_')) {
139+
$this->languageCodes[] = $language;
140+
$names[$language] = $name;
141+
} else {
142+
$localizedNames[$language] = $name;
143+
}
144+
}
135145
$data = [
136146
'Version' => $localeBundle['Version'],
137-
'Names' => self::generateLanguageNames($localeBundle),
147+
'Names' => $names,
148+
'LocalizedNames' => $localizedNames,
138149
];
139150

140-
$this->languageCodes = array_merge($this->languageCodes, array_keys($data['Names']));
141-
142151
return $data;
143152
}
144153

@@ -150,6 +159,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
150159
*/
151160
protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array
152161
{
162+
return null;
153163
}
154164

155165
/**

Data/Generator/LocaleDataGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
135135
*/
136136
protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array
137137
{
138+
return null;
138139
}
139140

140141
/**

Data/Generator/RegionDataGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
133133
*/
134134
protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array
135135
{
136+
return null;
136137
}
137138

138139
/**

Data/Generator/ScriptDataGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
8686
*/
8787
protected function generateDataForRoot(BundleEntryReaderInterface $reader, string $tempDir): ?array
8888
{
89+
return null;
8990
}
9091

9192
/**

Languages.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,25 @@ public static function exists(string $language): bool
5252
/**
5353
* Gets the language name from its alpha2 code.
5454
*
55+
* A full locale may be passed to obtain a more localized language name, e.g. "American English" for "en_US".
56+
*
5557
* @throws MissingResourceException if the language code does not exist
5658
*/
5759
public static function getName(string $language, string $displayLocale = null): string
5860
{
59-
return self::readEntry(['Names', $language], $displayLocale);
61+
try {
62+
return self::readEntry(['Names', $language], $displayLocale);
63+
} catch (MissingResourceException $e) {
64+
try {
65+
return self::readEntry(['LocalizedNames', $language], $displayLocale);
66+
} catch (MissingResourceException $e) {
67+
if (false !== $i = strrpos($language, '_')) {
68+
return self::getName(substr($language, 0, $i), $displayLocale);
69+
}
70+
71+
throw $e;
72+
}
73+
}
6074
}
6175

6276
/**

Resources/data/languages/af.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"an": "Aragonees",
1818
"anp": "Angika",
1919
"ar": "Arabies",
20-
"ar_001": "Moderne Standaardarabies",
2120
"arc": "Aramees",
2221
"arn": "Mapuche",
2322
"arp": "Arapaho",
@@ -71,7 +70,6 @@
7170
"dar": "Dakota",
7271
"dav": "Taita",
7372
"de": "Duits",
74-
"de_CH": "Switserse hoog-Duits",
7573
"dgr": "Dogrib",
7674
"dje": "Zarma",
7775
"dsb": "Benedesorbies",
@@ -87,8 +85,6 @@
8785
"eka": "Ekajuk",
8886
"el": "Grieks",
8987
"en": "Engels",
90-
"en_GB": "Engels (VK)",
91-
"en_US": "Engels (VSA)",
9288
"eo": "Esperanto",
9389
"es": "Spaans",
9490
"et": "Estnies",
@@ -252,14 +248,12 @@
252248
"nb": "Boeknoors",
253249
"nd": "Noord-Ndebele",
254250
"nds": "Lae Duits",
255-
"nds_NL": "Nedersaksies",
256251
"ne": "Nepalees",
257252
"new": "Newari",
258253
"ng": "Ndonga",
259254
"nia": "Nias",
260255
"niu": "Niueaans",
261256
"nl": "Nederlands",
262-
"nl_BE": "Vlaams",
263257
"nmg": "Kwasio",
264258
"nn": "Nuwe Noors",
265259
"nnh": "Ngiemboon",
@@ -394,10 +388,18 @@
394388
"yue": "Kantonees",
395389
"zgh": "Standaard Marokkaanse Tamazight",
396390
"zh": "Sjinees",
397-
"zh_Hans": "Chinees (Vereenvoudig)",
398-
"zh_Hant": "Chinees (Tradisioneel)",
399391
"zu": "Zoeloe",
400392
"zun": "Zuni",
401393
"zza": "Zaza"
394+
},
395+
"LocalizedNames": {
396+
"ar_001": "Moderne Standaardarabies",
397+
"de_CH": "Switserse hoog-Duits",
398+
"en_GB": "Engels (VK)",
399+
"en_US": "Engels (VSA)",
400+
"nds_NL": "Nedersaksies",
401+
"nl_BE": "Vlaams",
402+
"zh_Hans": "Chinees (Vereenvoudig)",
403+
"zh_Hant": "Chinees (Tradisioneel)"
402404
}
403405
}

Resources/data/languages/ak.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
"yo": "Yoruba",
4646
"zh": "Kyaena kasa",
4747
"zu": "Zulu"
48-
}
48+
},
49+
"LocalizedNames": []
4950
}

Resources/data/languages/am.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"an": "አራጎንስ",
2222
"anp": "አንጊካ",
2323
"ar": "ዓረብኛ",
24-
"ar_001": "ዘመናዊ መደበኛ ዓረብኛ",
2524
"arc": "አራማይክ",
2625
"arn": "ማፑቼ",
2726
"aro": "አራኦና",
@@ -107,8 +106,6 @@
107106
"dar": "ዳርግዋ",
108107
"dav": "ታይታኛ",
109108
"de": "ጀርመን",
110-
"de_AT": "የኦስትሪያ ጀርመን",
111-
"de_CH": "የስዊዝ ከፍተኛ ጀርመንኛ",
112109
"del": "ዳላዌር",
113110
"dgr": "ዶግሪብ",
114111
"din": "ዲንካ",
@@ -129,15 +126,8 @@
129126
"eka": "ኤካጁክ",
130127
"el": "ግሪክኛ",
131128
"en": "እንግሊዝኛ",
132-
"en_AU": "የአውስትራሊያ እንግሊዝኛ",
133-
"en_CA": "የካናዳ እንግሊዝኛ",
134-
"en_GB": "የብሪቲሽ እንግሊዝኛ",
135-
"en_US": "የአሜሪካ እንግሊዝኛ",
136129
"eo": "ኤስፐራንቶ",
137130
"es": "ስፓንሽኛ",
138-
"es_419": "የላቲን አሜሪካ ስፓኒሽ",
139-
"es_ES": "የአውሮፓ ስፓንሽኛ",
140-
"es_MX": "የሜክሲኮ ስፓንሽኛ",
141131
"esu": "ሴንተራል ዩፒክ",
142132
"et": "ኢስቶኒያንኛ",
143133
"eu": "ባስክኛ",
@@ -150,8 +140,6 @@
150140
"fo": "ፋሮኛ",
151141
"fon": "ፎን",
152142
"fr": "ፈረንሳይኛ",
153-
"fr_CA": "የካናዳ ፈረንሳይኛ",
154-
"fr_CH": "የስዊዝ ፈረንሳይኛ",
155143
"frc": "ካጁን ፍሬንች",
156144
"frp": "አርፒታን",
157145
"fur": "ፍሩሊያን",
@@ -303,15 +291,13 @@
303291
"nb": "የኖርዌይ ቦክማል",
304292
"nd": "ሰሜን ንዴብሌ",
305293
"nds": "የታችኛው ጀርመን",
306-
"nds_NL": "የታችኛው ሳክሰን",
307294
"ne": "ኔፓሊኛ",
308295
"new": "ኒዋሪ(ኔፓል)",
309296
"ng": "ንዶንጋ",
310297
"nia": "ኒአስ",
311298
"niu": "ኒዩአንኛ",
312299
"njo": "ኦ ናጋ",
313300
"nl": "ደች",
314-
"nl_BE": "ፍሌሚሽ",
315301
"nmg": "ክዋሲዮ",
316302
"nn": "የኖርዌይ ናይኖርስክ",
317303
"nnh": "ኒጊምቡን",
@@ -339,8 +325,6 @@
339325
"prg": "ፐሩሳንኛ",
340326
"ps": "ፓሽቶኛ",
341327
"pt": "ፖርቹጋልኛ",
342-
"pt_BR": "የብራዚል ፖርቹጋልኛ",
343-
"pt_PT": "የአውሮፓ ፖርቹጋልኛ",
344328
"qu": "ኵቿኛ",
345329
"quc": "ኪቼ",
346330
"qug": "ቺምቦራዞ ሃይላንድ ኩቹዋ",
@@ -349,7 +333,6 @@
349333
"rm": "ሮማንሽ",
350334
"rn": "ሩንዲኛ",
351335
"ro": "ሮማኒያን",
352-
"ro_MD": "ሞልዳቪያንኛ",
353336
"rof": "ሮምቦ",
354337
"ru": "ራሽያኛ",
355338
"rup": "አሮማንያን",
@@ -397,7 +380,6 @@
397380
"suk": "ሱኩማ",
398381
"sv": "ስዊድንኛ",
399382
"sw": "ስዋሂሊኛ",
400-
"sw_CD": "ኮንጎ ስዋሂሊ",
401383
"swb": "ኮሞሪያን",
402384
"syc": "ክላሲክ ኔይራ",
403385
"syr": "ሲሪያክ",
@@ -457,10 +439,30 @@
457439
"zbl": "ብሊስይምቦልስ",
458440
"zgh": "መደበኛ የሞሮኮ ታማዚግት",
459441
"zh": "ቻይንኛ",
460-
"zh_Hans": "ቀለል ያለ ቻይንኛ",
461-
"zh_Hant": "ባህላዊ ቻይንኛ",
462442
"zu": "ዙሉኛ",
463443
"zun": "ዙኒ",
464444
"zza": "ዛዛ"
445+
},
446+
"LocalizedNames": {
447+
"ar_001": "ዘመናዊ መደበኛ ዓረብኛ",
448+
"de_AT": "የኦስትሪያ ጀርመን",
449+
"de_CH": "የስዊዝ ከፍተኛ ጀርመንኛ",
450+
"en_AU": "የአውስትራሊያ እንግሊዝኛ",
451+
"en_CA": "የካናዳ እንግሊዝኛ",
452+
"en_GB": "የብሪቲሽ እንግሊዝኛ",
453+
"en_US": "የአሜሪካ እንግሊዝኛ",
454+
"es_419": "የላቲን አሜሪካ ስፓኒሽ",
455+
"es_ES": "የአውሮፓ ስፓንሽኛ",
456+
"es_MX": "የሜክሲኮ ስፓንሽኛ",
457+
"fr_CA": "የካናዳ ፈረንሳይኛ",
458+
"fr_CH": "የስዊዝ ፈረንሳይኛ",
459+
"nds_NL": "የታችኛው ሳክሰን",
460+
"nl_BE": "ፍሌሚሽ",
461+
"pt_BR": "የብራዚል ፖርቹጋልኛ",
462+
"pt_PT": "የአውሮፓ ፖርቹጋልኛ",
463+
"ro_MD": "ሞልዳቪያንኛ",
464+
"sw_CD": "ኮንጎ ስዋሂሊ",
465+
"zh_Hans": "ቀለል ያለ ቻይንኛ",
466+
"zh_Hant": "ባህላዊ ቻይንኛ"
465467
}
466468
}

0 commit comments

Comments
 (0)