r106864 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106863‎ | r106864 | r106865 >
Date:21:24, 20 December 2011
Author:brion
Status:ok
Tags:
Comment:
Provisional revert r106573, r106559: may be the wrong thing to do, and should probably come with regression tests if added.
Modified paths:
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -604,15 +604,21 @@
605605 * Gives language names.
606606 * @param $parser Parser
607607 * @param $code String Language code
608 - * @param $inLanguage String Language code
 608+ * @param $language String Language code
609609 * @return String
610610 */
611 - static function language( $parser, $code = '', $inLanguage = '' ) {
 611+ static function language( $parser, $code = '', $language = '' ) {
 612+ global $wgContLang;
612613 $code = strtolower( $code );
613 - # default to native language name
614 - $inLanguage = $inLanguage !== '' ? strtolower( $inLanguage ) : $code;
615 - $names = Language::getTranslatedLanguageNames( $inLanguage );
616 - return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code );
 614+ $language = strtolower( $language );
 615+
 616+ if ( $language !== '' ) {
 617+ $names = Language::getTranslatedLanguageNames( $language );
 618+ return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code );
 619+ }
 620+
 621+ $lang = $wgContLang->getLanguageName( $code );
 622+ return $lang !== '' ? $lang : wfBCP47( $code );
617623 }
618624
619625 /**
Index: trunk/phase3/languages/Language.php
@@ -682,12 +682,8 @@
683683 $names = array();
684684 wfRunHooks( 'LanguageGetTranslatedLanguageNames', array( &$names, $code ) );
685685
686 - foreach ( self::getLanguageNames() as $code2 => $name ) {
687 - # Prefer own MediaWiki native name,
688 - # for other names just add if not added through the hook
689 - if ( $code === $code2 || !isset( $names[$code2] ) ) {
690 - $names[$code2] = $name;
691 - }
 686+ foreach ( self::getLanguageNames() as $code => $name ) {
 687+ if ( !isset( $names[$code] ) ) $names[$code] = $name;
692688 }
693689
694690 return $names;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106559Make the output consistent when no second parameter is given and second param...robin12:17, 18 December 2011
r106573Follow-up r106559: it's better to set the preference for own MediaWiki names ...robin17:58, 18 December 2011

Status & tagging log