r40903 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40902‎ | r40903 | r40904 >
Date:08:48, 16 September 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Do not prefer local names from Names.php because they can be inconsistent. Use them as last resort
only.
* Fixes bug 15576
Modified paths:
  • /trunk/extensions/cldr/LanguageNames.body.php (modified) (history)
  • /trunk/extensions/cldr/LanguageNames.php (modified) (history)

Diff [purge]

Index: trunk/extensions/cldr/LanguageNames.php
@@ -13,7 +13,7 @@
1414
1515 $wgExtensionCredits['other'][] = array(
1616 'name' => 'Language Names',
17 - 'version' => '1.4 (CLDR 1.6.0)',
 17+ 'version' => '1.5 (CLDR 1.6.0)',
1818 'author' => 'Niklas Laxström',
1919 'url' => 'http://unicode.org/cldr/repository_access.html',
2020 'description' => 'Extension which provides localised language names',
Index: trunk/extensions/cldr/LanguageNames.body.php
@@ -11,20 +11,20 @@
1212
1313 private static $cache = array();
1414
15 - const FALLBACK_NATIVE = 0;
16 - const FALLBACK_NORMAL = 1;
17 - const LIST_MW_SUPPORTED = 0;
18 - const LIST_MW = 1;
19 - const LIST_MW_AND_CLDR = 2;
 15+ const FALLBACK_NATIVE = 0; // Missing entries fallback to native name
 16+ const FALLBACK_NORMAL = 1; // Missing entries fallback trough fallback chain
 17+ const LIST_MW_SUPPORTED = 0; // Only names that has localisation in MediaWiki
 18+ const LIST_MW = 1; // All names that are in Names.php
 19+ const LIST_MW_AND_CLDR = 2; // Combination of Names.php and what is in cldr
2020
2121
22 - public static function getNames( $code, $fallback = self::FALLBACK_NATIVE, $list = self::LIST_MW ) {
 22+ public static function getNames( $code, $fbMethod = self::FALLBACK_NATIVE, $list = self::LIST_MW ) {
2323 $xx = self::loadLanguage( $code );
2424 $native = Language::getLanguageNames( $list === self::LIST_MW_SUPPORTED );
2525
26 - if ( $fallback === self::FALLBACK_NATIVE ) {
 26+ if ( $fbMethod === self::FALLBACK_NATIVE ) {
2727 $names = array_merge( $native, $xx );
28 - } elseif ( $fallback === self::FALLBACK_NORMAL ) {
 28+ } elseif ( $fbMethod === self::FALLBACK_NORMAL ) {
2929 $fallback = $code;
3030 $fb = $xx;
3131 while ( $fallback = Language::getFallbackFor( $fallback ) ) {
@@ -35,10 +35,8 @@
3636 /* Add native names for codes that are not in cldr */
3737 $names = array_merge( $native, $fb );
3838
39 - /* Special case for native name for $code language, which is already
40 - * provided by MediaWiki.
41 - */
42 - if ( isset( $native[$code] ) ) {
 39+ /* As a last resort, try the native name in Names.php */
 40+ if ( !isset( $names[$code] ) && isset( $native[$code] ) ) {
4341 $names[$code] = $native[$code];
4442 }
4543 } else {