Skip to content

Commit 894ce3c

Browse files
committed
[Intl] Fix the update-data.php script in preparation for ICU 5.5
1 parent d2e5c4c commit 894ce3c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class LanguageDataGenerator extends AbstractDataGenerator
4949
'fr' => 'fra',
5050
'gn' => 'grn',
5151
'hy' => 'hye',
52+
'hr' => 'hrv',
5253
'ik' => 'ipk',
5354
'is' => 'isl',
5455
'iu' => 'iku',
@@ -76,6 +77,7 @@ class LanguageDataGenerator extends AbstractDataGenerator
7677
'sc' => 'srd',
7778
'sk' => 'slk',
7879
'sq' => 'sqi',
80+
'sr' => 'srp',
7981
'sw' => 'swa',
8082
'uz' => 'uzb',
8183
'yi' => 'yid',
@@ -164,10 +166,13 @@ protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir)
164166

165167
private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $metadataBundle)
166168
{
167-
$aliases = $metadataBundle['languageAlias'];
169+
// Data structure has changed in ICU 5.5 from "languageAlias" to "alias->language"
170+
$aliases = $metadataBundle['languageAlias'] ?: $metadataBundle['alias']['language'];
168171
$alpha2ToAlpha3 = array();
169172

170173
foreach ($aliases as $alias => $language) {
174+
// $language is a string before ICU 5.5
175+
$language = is_string($language) ? $language : $language['replacement'];
171176
if (2 === strlen($language) && 3 === strlen($alias)) {
172177
if (isset(self::$preferredAlpha2ToAlpha3Mapping[$language])) {
173178
// Validate to prevent typos
@@ -181,12 +186,13 @@ private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $me
181186
}
182187

183188
$alpha3 = self::$preferredAlpha2ToAlpha3Mapping[$language];
189+
$alpha2 = is_string($aliases[$alpha3]) ? $aliases[$alpha3] : $aliases[$alpha3]['replacement'];
184190

185-
if ($language !== $aliases[$alpha3]) {
191+
if ($language !== $alpha2) {
186192
throw new RuntimeException(
187193
'The statically set three-letter mapping '.$alpha3.' '.
188194
'for the language code '.$language.' seems to be '.
189-
'an alias for '.$aliases[$alpha3].'. Wrong mapping?'
195+
'an alias for '.$alpha2.'. Wrong mapping?'
190196
);
191197
}
192198

src/Symfony/Component/Intl/Resources/bin/icu.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
51 = http://source.icu-project.org/repos/icu/icu/tags/release-51-2/source
1111
52 = http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source
1212
53 = http://source.icu-project.org/repos/icu/icu/tags/release-53-1/source
13-
54 = http://source.icu-project.org/repos/icu/icu/tags/release-54-rc/source
13+
54 = http://source.icu-project.org/repos/icu/icu/tags/release-54-1/source
14+
55 = http://source.icu-project.org/repos/icu/icu/tags/release-55-1/source

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy