Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -604,21 +604,28 @@ |
605 | 605 | * Gives language names. |
606 | 606 | * @param $parser Parser |
607 | 607 | * @param $code String Language code |
608 | | - * @param $language String Language code |
| 608 | + * @param $inLanguage String Language code |
609 | 609 | * @return String |
610 | 610 | */ |
611 | | - static function language( $parser, $code = '', $language = '' ) { |
612 | | - global $wgContLang; |
| 611 | + static function language( $parser, $code = '', $inLanguage = '' ) { |
613 | 612 | $code = strtolower( $code ); |
614 | | - $language = strtolower( $language ); |
| 613 | + $inLanguage = strtolower( $inLanguage ); |
615 | 614 | |
616 | | - if ( $language !== '' ) { |
617 | | - $names = Language::getTranslatedLanguageNames( $language ); |
618 | | - return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code ); |
| 615 | + if( $inLanguage === $code || $inLanguage === '' ) { |
| 616 | + # Make sure the output is the same when the second parameter |
| 617 | + # is the same language |
| 618 | + global $wgContLang; |
| 619 | + $name = $wgContLang->getLanguageName( $code ); |
| 620 | + if( $name !== '' ) { |
| 621 | + return $name; |
| 622 | + } else { |
| 623 | + # Try if there is a language name below |
| 624 | + $inLanguage = $code; |
| 625 | + } |
619 | 626 | } |
620 | 627 | |
621 | | - $lang = $wgContLang->getLanguageName( $code ); |
622 | | - return $lang !== '' ? $lang : wfBCP47( $code ); |
| 628 | + $names = Language::getTranslatedLanguageNames( $inLanguage ); |
| 629 | + return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code ); |
623 | 630 | } |
624 | 631 | |
625 | 632 | /** |