Skip to content

Commit

Permalink
feature #31318 [Intl] Compile localized timezone offset name (ro0NL)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.3-dev branch.

Discussion
----------

[Intl] Compile localized timezone offset name

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes-ish
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes (including intl-data group)
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

A tiny follow up of #31295

Commits
-------

7a40d20 [Intl] Compile localized timezone offset name
  • Loading branch information
fabpot committed Apr 29, 2019
2 parents 0c78413 + 7a40d20 commit 8fdcd6e
Show file tree
Hide file tree
Showing 145 changed files with 914 additions and 26 deletions.
Expand Up @@ -86,21 +86,25 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir
if ('root' !== $displayLocale) {
$localeBundles[] = $reader->read($tempDir, 'root');
}
$metadata = [];
$data = [
'Version' => $localeBundle['Version'],
'Names' => $this->generateZones(
$displayLocale,
$reader->read($tempDir, 'timezoneTypes'),
$reader->read($tempDir, 'metaZones'),
$reader->read($tempDir, 'windowsZones'),
...$localeBundles
$localeBundles,
$metadata
),
];

if (!$data['Names']) {
if (!$data['Names'] && !$metadata) {
return;
}

$data['Meta'] = $metadata;

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

return $data;
Expand Down Expand Up @@ -136,7 +140,10 @@ protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir)
return $data;
}

private function generateZones(string $locale, ArrayAccessibleResourceBundle $typeBundle, ArrayAccessibleResourceBundle $metaBundle, ArrayAccessibleResourceBundle $windowsZonesBundle, ArrayAccessibleResourceBundle ...$localeBundles): array
/**
* @param ArrayAccessibleResourceBundle[] $localeBundles
*/
private function generateZones(string $locale, ArrayAccessibleResourceBundle $typeBundle, ArrayAccessibleResourceBundle $metaBundle, ArrayAccessibleResourceBundle $windowsZonesBundle, array $localeBundles, array &$metadata = []): array
{
$accessor = static function (ArrayAccessibleResourceBundle $resourceBundle, array $indices) {
$result = $resourceBundle;
Expand Down Expand Up @@ -234,6 +241,16 @@ private function generateZones(string $locale, ArrayAccessibleResourceBundle $ty
$zones[$id] = $name;
}

$gmtFormat = $accessor(['zoneStrings', 'gmtFormat'], $gmtFormatInherited) ?? 'GMT{0}';
if (!$gmtFormatInherited || $isBase) {
$metadata['GmtFormat'] = str_replace('{0}', '%s', $gmtFormat);
}

$hourFormat = $accessor(['zoneStrings', 'hourFormat'], $hourFormatInherited) ?? '+HH:mm;-HH:mm';
if (!$hourFormatInherited || $isBase) {
$metadata['HourFormat'] = explode(';', str_replace(['HH', 'mm', 'H', 'm'], ['%02d', '%02d', '%d', '%d'], $hourFormat), 2);
}

return $zones;
}

Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/af.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Chuuk-tyd",
"Pacific\/Wake": "Wake-eiland-tyd",
"Pacific\/Wallis": "Wallis en Futuna-tyd (Mata-Utu)"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/am.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "የቹክ ሰዓት",
"Pacific\/Wake": "የዌክ ደሴት ሰዓት (ዋኬ)",
"Pacific\/Wallis": "የዋሊስ እና ፉቱና ሰዓት"
},
"Meta": {
"GmtFormat": "ጂ ኤም ቲ%s",
"HourFormat": [
"+%02d%02d",
"-%02d%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/ar.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "توقيت شوك (ترك)",
"Pacific\/Wake": "توقيت جزيرة ويك (واك)",
"Pacific\/Wallis": "توقيت واليس و فوتونا"
},
"Meta": {
"GmtFormat": "غرينتش%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/as.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "চ্চুকৰ সময়",
"Pacific\/Wake": "ৱেক দ্বীপৰ সময়",
"Pacific\/Wallis": "ৱালিছ আৰু ফুটুনাৰ সময়"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/az.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Çuuk Vaxtı",
"Pacific\/Wake": "Ueyk Vaxtı (Veyk)",
"Pacific\/Wallis": "Uollis və Futuna Vaxtı"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/be.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Час Чуук",
"Pacific\/Wake": "Час вострава Уэйк",
"Pacific\/Wallis": "Час астравоў Уоліс і Футуна"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d.%02d",
"-%02d.%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/bg.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Чуюк",
"Pacific\/Wake": "Остров Уейк",
"Pacific\/Wallis": "Уолис и Футуна"
},
"Meta": {
"GmtFormat": "Гринуич%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/bn.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "চুক সময়",
"Pacific\/Wake": "ওয়েক দ্বীপ সময়",
"Pacific\/Wallis": "ওয়ালিস এবং ফুটুনা সময় (ওলিস)"
},
"Meta": {
"GmtFormat": "GMT %s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/bo.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Micronesia (Chuuk)",
"Pacific\/Wake": "U.S. Outlying Islands (Wake)",
"Pacific\/Wallis": "Wallis & Futuna (Wallis)"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/br.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Mikronezia (Chuuk)",
"Pacific\/Wake": "Inizi diabell ar Stadoù-Unanet (Wake)",
"Pacific\/Wallis": "eur Wallis ha Futuna"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/bs.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Čučko vrijeme (Chuuk)",
"Pacific\/Wake": "Vrijeme na Ostrvu Vejk (Wake)",
"Pacific\/Wallis": "Vrijeme na Ostrvima Valis i Futuna"
},
"Meta": {
"GmtFormat": "GMT %s",
"HourFormat": [
"+%02d:%02d",
" -%02d:%02d"
]
}
}
Expand Up @@ -429,5 +429,12 @@
"Pacific\/Truk": "Трук време",
"Pacific\/Wake": "Вејк острво време",
"Pacific\/Wallis": "Валис и Футуна Острва време"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d%02d",
"-%02d%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/ca.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Hora de Chuuk",
"Pacific\/Wake": "Hora de Wake",
"Pacific\/Wallis": "Hora de Wallis i Futuna"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/ce.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Чуук (Трук, гӀ-наш)",
"Pacific\/Wake": "Уэйк, гӀ-е",
"Pacific\/Wallis": "Уоллис а, Футуна а"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/cs.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Chuukský čas (Chuukské ostrovy)",
"Pacific\/Wake": "Čas ostrova Wake",
"Pacific\/Wallis": "Čas ostrovů Wallis a Futuna"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%d:%02d",
"-%d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/cy.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Amser Chuuk",
"Pacific\/Wake": "Amser Ynys Wake",
"Pacific\/Wallis": "Amser Wallis a Futuna"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/da.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Chuuk-tid",
"Pacific\/Wake": "Wake Island-tid",
"Pacific\/Wallis": "Wallis og Futuna-tid"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d.%02d",
"-%02d.%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/de.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Chuuk-Zeit",
"Pacific\/Wake": "Wake-Insel-Zeit",
"Pacific\/Wallis": "Wallis-und-Futuna-Zeit"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
Expand Up @@ -5,5 +5,6 @@
"Asia\/Macau": "Chinesische Zeit (Macao)",
"Europe\/Saratov": "Moskauer Zeit (Saratov)",
"Pacific\/Guadalcanal": "Salomoninseln-Zeit (Guadalcanal)"
}
},
"Meta": []
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/dz.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "མའི་ཀྲོ་ནི་ཤི་ཡ། (Chuuk་)",
"Pacific\/Wake": "ཡུ་ཨེས་གྱི་མཐའ་མཚམས་མཚོ་གླིང་། (Wake་)",
"Pacific\/Wallis": "ཝལ་ལིས྄་ ཨེནཌ་ ཕུ་ཏུ་ན་། (Wallis་)"
},
"Meta": {
"GmtFormat": "ཇི་ཨེམ་ཏི་%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/ee.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Chuuk gaƒoƒo me",
"Pacific\/Wake": "Wake Island gaƒoƒo me",
"Pacific\/Wallis": "Wallis & Futuna gaƒoƒo me"
},
"Meta": {
"GmtFormat": "%s GMT",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/el.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Ώρα Τσουκ",
"Pacific\/Wake": "Ώρα Νήσου Γουέικ",
"Pacific\/Wallis": "[Ώρα Ουάλις και Φουτούνα (Γουάλις)]"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/en.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "Chuuk Time",
"Pacific\/Wake": "Wake Island Time",
"Pacific\/Wallis": "Wallis & Futuna Time"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}
Expand Up @@ -34,5 +34,6 @@
"Indian\/Comoro": "Eastern Africa Time (Comoro)",
"Indian\/Mayotte": "Eastern Africa Time (Mayotte)",
"Pacific\/Rarotonga": "Cook Island Time (Rarotonga)"
}
},
"Meta": []
}
Expand Up @@ -2,5 +2,6 @@
"Version": "2.1.47.86",
"Names": {
"Asia\/Rangoon": "Myanmar Time (Rangoon)"
}
},
"Meta": []
}
Expand Up @@ -9,5 +9,6 @@
"America\/St_Thomas": "Atlantic Time (St Thomas)",
"America\/St_Vincent": "Atlantic Time (St Vincent)",
"Atlantic\/St_Helena": "Greenwich Mean Time (St Helena)"
}
},
"Meta": []
}
Expand Up @@ -2,5 +2,6 @@
"Version": "2.1.49.14",
"Names": {
"Asia\/Rangoon": "Myanmar Time (Rangoon)"
}
},
"Meta": []
}
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Resources/data/timezones/es.json
Expand Up @@ -435,5 +435,12 @@
"Pacific\/Truk": "hora de Chuuk",
"Pacific\/Wake": "hora de la isla Wake",
"Pacific\/Wallis": "hora de Wallis y Futuna"
},
"Meta": {
"GmtFormat": "GMT%s",
"HourFormat": [
"+%02d:%02d",
"-%02d:%02d"
]
}
}

0 comments on commit 8fdcd6e

Please sign in to comment.