[Intl] Fix the update-data.php script in preparation for ICU 5.5
This commit is contained in:
parent
d2e5c4c3ab
commit
894ce3cbd8
@ -49,6 +49,7 @@ class LanguageDataGenerator extends AbstractDataGenerator
|
|||||||
'fr' => 'fra',
|
'fr' => 'fra',
|
||||||
'gn' => 'grn',
|
'gn' => 'grn',
|
||||||
'hy' => 'hye',
|
'hy' => 'hye',
|
||||||
|
'hr' => 'hrv',
|
||||||
'ik' => 'ipk',
|
'ik' => 'ipk',
|
||||||
'is' => 'isl',
|
'is' => 'isl',
|
||||||
'iu' => 'iku',
|
'iu' => 'iku',
|
||||||
@ -76,6 +77,7 @@ class LanguageDataGenerator extends AbstractDataGenerator
|
|||||||
'sc' => 'srd',
|
'sc' => 'srd',
|
||||||
'sk' => 'slk',
|
'sk' => 'slk',
|
||||||
'sq' => 'sqi',
|
'sq' => 'sqi',
|
||||||
|
'sr' => 'srp',
|
||||||
'sw' => 'swa',
|
'sw' => 'swa',
|
||||||
'uz' => 'uzb',
|
'uz' => 'uzb',
|
||||||
'yi' => 'yid',
|
'yi' => 'yid',
|
||||||
@ -164,10 +166,13 @@ class LanguageDataGenerator extends AbstractDataGenerator
|
|||||||
|
|
||||||
private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $metadataBundle)
|
private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $metadataBundle)
|
||||||
{
|
{
|
||||||
$aliases = $metadataBundle['languageAlias'];
|
// Data structure has changed in ICU 5.5 from "languageAlias" to "alias->language"
|
||||||
|
$aliases = $metadataBundle['languageAlias'] ?: $metadataBundle['alias']['language'];
|
||||||
$alpha2ToAlpha3 = array();
|
$alpha2ToAlpha3 = array();
|
||||||
|
|
||||||
foreach ($aliases as $alias => $language) {
|
foreach ($aliases as $alias => $language) {
|
||||||
|
// $language is a string before ICU 5.5
|
||||||
|
$language = is_string($language) ? $language : $language['replacement'];
|
||||||
if (2 === strlen($language) && 3 === strlen($alias)) {
|
if (2 === strlen($language) && 3 === strlen($alias)) {
|
||||||
if (isset(self::$preferredAlpha2ToAlpha3Mapping[$language])) {
|
if (isset(self::$preferredAlpha2ToAlpha3Mapping[$language])) {
|
||||||
// Validate to prevent typos
|
// Validate to prevent typos
|
||||||
@ -181,12 +186,13 @@ class LanguageDataGenerator extends AbstractDataGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
$alpha3 = self::$preferredAlpha2ToAlpha3Mapping[$language];
|
$alpha3 = self::$preferredAlpha2ToAlpha3Mapping[$language];
|
||||||
|
$alpha2 = is_string($aliases[$alpha3]) ? $aliases[$alpha3] : $aliases[$alpha3]['replacement'];
|
||||||
|
|
||||||
if ($language !== $aliases[$alpha3]) {
|
if ($language !== $alpha2) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
'The statically set three-letter mapping '.$alpha3.' '.
|
'The statically set three-letter mapping '.$alpha3.' '.
|
||||||
'for the language code '.$language.' seems to be '.
|
'for the language code '.$language.' seems to be '.
|
||||||
'an alias for '.$aliases[$alpha3].'. Wrong mapping?'
|
'an alias for '.$alpha2.'. Wrong mapping?'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,4 +10,5 @@
|
|||||||
51 = http://source.icu-project.org/repos/icu/icu/tags/release-51-2/source
|
51 = http://source.icu-project.org/repos/icu/icu/tags/release-51-2/source
|
||||||
52 = http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source
|
52 = http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source
|
||||||
53 = http://source.icu-project.org/repos/icu/icu/tags/release-53-1/source
|
53 = http://source.icu-project.org/repos/icu/icu/tags/release-53-1/source
|
||||||
54 = http://source.icu-project.org/repos/icu/icu/tags/release-54-rc/source
|
54 = http://source.icu-project.org/repos/icu/icu/tags/release-54-1/source
|
||||||
|
55 = http://source.icu-project.org/repos/icu/icu/tags/release-55-1/source
|
||||||
|
Reference in New Issue
Block a user