Skip to content

Commit 83e780a

Browse files
Merge branch '6.4' into 7.3
* 6.4: [Intl] Take timezoneTypes’ ianaMap into account
2 parents da26e42 + ab6a579 commit 83e780a

Some content is hidden

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

145 files changed

+2526
-4
lines changed

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class TimezoneDataGenerator extends AbstractDataGenerator
3737
private array $zoneIds = [];
3838
private array $zoneToCountryMapping = [];
3939
private array $localeAliases = [];
40+
private array $ianaMap = [];
4041

4142
protected function scanLocales(LocaleScanner $scanner, string $sourceDir): array
4243
{
@@ -64,8 +65,14 @@ protected function preGenerate(): void
6465

6566
protected function generateDataForLocale(BundleEntryReaderInterface $reader, string $tempDir, string $displayLocale): ?array
6667
{
68+
if (!$this->ianaMap) {
69+
foreach ($reader->readEntry($tempDir, 'timezoneTypes', ['ianaMap', 'timezone']) as $cldr => $iana) {
70+
$this->ianaMap[str_replace(':', '/', $cldr)] = $iana;
71+
}
72+
}
73+
6774
if (!$this->zoneToCountryMapping) {
68-
$this->zoneToCountryMapping = self::generateZoneToCountryMapping($reader->read($tempDir, 'windowsZones'));
75+
$this->zoneToCountryMapping = $this->generateZoneToCountryMapping($reader->read($tempDir, 'windowsZones'));
6976
}
7077

7178
// Don't generate aliases, as they are resolved during runtime
@@ -76,7 +83,7 @@ protected function generateDataForLocale(BundleEntryReaderInterface $reader, str
7683

7784
$localeBundle = $reader->read($tempDir, $displayLocale);
7885

79-
if (!isset($localeBundle['zoneStrings']) || null === $localeBundle['zoneStrings']) {
86+
if (!isset($localeBundle['zoneStrings'])) {
8087
return null;
8188
}
8289

@@ -217,6 +224,10 @@ private function generateZones(BundleEntryReaderInterface $reader, string $tempD
217224
}
218225

219226
$zones[$id] = $name;
227+
228+
if (isset($this->ianaMap[$id])) {
229+
$zones[$this->ianaMap[$id]] = $name;
230+
}
220231
}
221232

222233
return $zones;
@@ -237,14 +248,20 @@ private static function generateZoneMetadata(ArrayAccessibleResourceBundle $loca
237248
return $metadata;
238249
}
239250

240-
private static function generateZoneToCountryMapping(ArrayAccessibleResourceBundle $windowsZoneBundle): array
251+
private function generateZoneToCountryMapping(ArrayAccessibleResourceBundle $windowsZoneBundle): array
241252
{
242253
$mapping = [];
243254

244255
foreach ($windowsZoneBundle['mapTimezones'] as $zoneInfo) {
245256
foreach ($zoneInfo as $region => $zones) {
246257
if (RegionDataGenerator::isValidCountryCode($region)) {
247-
$mapping += array_fill_keys(explode(' ', $zones), $region);
258+
foreach (explode(' ', $zones) as $zone) {
259+
$mapping[$zone] = $region;
260+
261+
if (isset($this->ianaMap[$zone])) {
262+
$mapping[$this->ianaMap[$zone]] = $region;
263+
}
264+
}
248265
}
249266
}
250267
}

src/Symfony/Component/Intl/Resources/data/timezones/af.php

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Symfony/Component/Intl/Resources/data/timezones/ak.php

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)