Index: trunk/extensions/cldr/CountryNames.body.php |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | $names = self::loadLanguage( $code ); |
30 | 30 | |
31 | 31 | // Load missing country names from fallback languages |
32 | | - $fallbacks = Language::getFallbacksFor( $code ); |
33 | | - foreach ( $fallbacks as $fallback ) { |
| 32 | + $fallback = $code; |
| 33 | + while ( $fallback = Language::getFallbackFor( $fallback ) ) { |
34 | 34 | // Overwrite the things in fallback with what we have already |
35 | 35 | $names = array_merge( self::loadLanguage( $fallback ), $names ); |
36 | 36 | } |
— | — | @@ -40,6 +40,8 @@ |
41 | 41 | unset( $names['IR'] ); // Iran |
42 | 42 | unset( $names['SY'] ); // Syria |
43 | 43 | } |
| 44 | + |
| 45 | + return $names; |
44 | 46 | } |
45 | 47 | |
46 | 48 | /** |
— | — | @@ -49,7 +51,39 @@ |
50 | 52 | * @return an associative array of country codes and localized country names |
51 | 53 | */ |
52 | 54 | private static function loadLanguage( $code ) { |
53 | | - // TODO: Build this. |
| 55 | + if ( !isset( self::$cache[$code] ) ) { |
| 56 | + wfProfileIn( __METHOD__.'-recache' ); |
| 57 | + |
| 58 | + /* Load override for wrong or missing entries in cldr */ |
| 59 | + $override = dirname(__FILE__) . '/LocalNames/' . self::getOverrideFileName( $code ); |
| 60 | + if ( Language::isValidBuiltInCode( $code ) && file_exists( $override ) ) { |
| 61 | + $countryNames = false; |
| 62 | + require( $override ); |
| 63 | + if ( is_array( $countryNames ) ) { |
| 64 | + self::$cache[$code] = $countryNames; |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + $filename = dirname(__FILE__) . '/CldrNames/' . self::getFileName( $code ); |
| 69 | + if ( Language::isValidBuiltInCode( $code ) && file_exists( $filename ) ) { |
| 70 | + $countryNames = false; |
| 71 | + require( $filename ); |
| 72 | + if ( is_array( $countryNames ) ) { |
| 73 | + if ( isset( self::$cache[$code] ) ) { |
| 74 | + // Add to existing list of localized country names |
| 75 | + self::$cache[$code] = self::$cache[$code] + $countryNames; |
| 76 | + } else { |
| 77 | + // No list exists, so create it |
| 78 | + self::$cache[$code] = $countryNames; |
| 79 | + } |
| 80 | + } |
| 81 | + } else { |
| 82 | + wfDebug( __METHOD__ . ": Unable to load country names for $filename\n" ); |
| 83 | + } |
| 84 | + wfProfileOut( __METHOD__.'-recache' ); |
| 85 | + } |
| 86 | + |
| 87 | + return isset( self::$cache[$code] ) ? self::$cache[$code] : array(); |
54 | 88 | } |
55 | 89 | |
56 | 90 | /** |
Index: trunk/extensions/cldr/LanguageNames.body.php |
— | — | @@ -33,9 +33,9 @@ |
34 | 34 | if ( $fbMethod === self::FALLBACK_NATIVE ) { |
35 | 35 | $names = array_merge( $native, $xx ); |
36 | 36 | } elseif ( $fbMethod === self::FALLBACK_NORMAL ) { |
37 | | - $fallbacks = Language::getFallbacksFor( $code ); |
| 37 | + $fallback = $code; |
38 | 38 | $fb = $xx; |
39 | | - foreach ( $fallbacks as $fallback ) { |
| 39 | + while ( $fallback = Language::getFallbackFor( $fallback ) ) { |
40 | 40 | /* Overwrite the things in fallback with what we have already */ |
41 | 41 | $fb = array_merge( self::loadLanguage( $fallback ), $fb ); |
42 | 42 | } |
Index: trunk/extensions/cldr/cldr.php |
— | — | @@ -13,8 +13,8 @@ |
14 | 14 | $wgExtensionCredits['other'][] = array( |
15 | 15 | 'path' => __FILE__, |
16 | 16 | 'name' => 'Language Names', |
17 | | - 'version' => '1.9.0 (CLDR 1.9M2)', |
18 | | - 'author' => array( 'Niklas Laxström', 'Siebrand Mazeland' ), |
| 17 | + 'version' => '2.0.0 (CLDR 2.0)', |
| 18 | + 'author' => array( 'Niklas Laxström', 'Siebrand Mazeland', 'Ryan Kaldari' ), |
19 | 19 | 'url' => 'https://www.mediawiki.org/wiki/Extension:CLDR', |
20 | 20 | 'descriptionmsg' => 'cldr-desc', |
21 | 21 | ); |
— | — | @@ -22,4 +22,5 @@ |
23 | 23 | $dir = dirname(__FILE__) . '/'; |
24 | 24 | $wgExtensionMessagesFiles['cldr'] = $dir . 'cldr.i18n.php'; |
25 | 25 | $wgAutoloadClasses['LanguageNames'] = $dir . 'LanguageNames.body.php'; |
| 26 | +$wgAutoloadClasses['CountryNames'] = $dir . 'CountryNames.body.php'; |
26 | 27 | $wgHooks['LanguageGetTranslatedLanguageNames'][] = 'LanguageNames::coreHook'; |