From: Robin Pepermans Date: Sun, 18 Dec 2011 12:17:12 +0000 (+0000) Subject: Make the output consistent when no second parameter is given and second parameter... X-Git-Tag: 1.31.0-rc.0~25913 X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=commitdiff_plain;h=8cae5ee72d2a187016692b16581298607d82de9b;p=lhc%2Fweb%2Fwiklou.git Make the output consistent when no second parameter is given and second parameter equals first parameter. This gives preference to names defined in MediaWiki, but when it is not in MediaWiki, it also sees whether there is one defined in the translated language names. --- diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index cd5e0a5665..25278e9788 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -604,21 +604,28 @@ class CoreParserFunctions { * Gives language names. * @param $parser Parser * @param $code String Language code - * @param $language String Language code + * @param $inLanguage String Language code * @return String */ - static function language( $parser, $code = '', $language = '' ) { - global $wgContLang; + static function language( $parser, $code = '', $inLanguage = '' ) { $code = strtolower( $code ); - $language = strtolower( $language ); + $inLanguage = strtolower( $inLanguage ); - if ( $language !== '' ) { - $names = Language::getTranslatedLanguageNames( $language ); - return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code ); + if( $inLanguage === $code || $inLanguage === '' ) { + # Make sure the output is the same when the second parameter + # is the same language + global $wgContLang; + $name = $wgContLang->getLanguageName( $code ); + if( $name !== '' ) { + return $name; + } else { + # Try if there is a language name below + $inLanguage = $code; + } } - $lang = $wgContLang->getLanguageName( $code ); - return $lang !== '' ? $lang : wfBCP47( $code ); + $names = Language::getTranslatedLanguageNames( $inLanguage ); + return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code ); } /**