r113385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113384‎ | r113385 | r113386 >
Date:19:30, 8 March 2012
Author:robin
Status:ok
Tags:
Comment:
Follow-up r112479
* Add @since, fix indentation.
* Change default from 'all' to 'mw' as it's the most used (so default fetchLanguageNames() is equivalent to default getLanguageNames()).
* Add the include parameter also to fetchLanguageName() as it's needed in Parser: interlanguage links should only take into account mediawiki names. (Doesn't make a difference with how the functions are now, but could have been later.)
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -1901,11 +1901,9 @@
19021902
19031903 # Link not escaped by : , create the various objects
19041904 if ( $noforce ) {
1905 - global $wgContLang;
1906 -
19071905 # Interwikis
19081906 wfProfileIn( __METHOD__."-interwiki" );
1909 - if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw ) ) {
 1907+ if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' ) ) {
19101908 $this->mOutput->addLanguageLink( $nt->getFullText() );
19111909 $s = rtrim( $s . $prefix );
19121910 $s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail;
Index: trunk/phase3/languages/Language.php
@@ -682,14 +682,15 @@
683683 /**
684684 * Get an array of language names, indexed by code.
685685 * @param $inLanguage null|string: Code of language in which to return the names
686 - * Use null for autonyms (native names)
 686+ * Use null for autonyms (native names)
687687 * @param $include string:
688688 * 'all' all available languages
689689 * 'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames
690690 * 'mwfile' only if the language is in 'mw' *and* has a message file
691691 * @return array|bool: language code => language name, false if $include is wrong
 692+ * @since 1.20
692693 */
693 - public static function fetchLanguageNames( $inLanguage = null, $include = 'all' ) {
 694+ public static function fetchLanguageNames( $inLanguage = null, $include = 'mw' ) {
694695 global $wgExtraLanguageNames;
695696 static $coreLanguageNames;
696697
@@ -743,11 +744,12 @@
744745 /**
745746 * @param $code string: The code of the language for which to get the name
746747 * @param $inLanguage null|string: Code of language in which to return the name (null for autonyms)
 748+ * @param $include string: 'all', 'mw' or 'mwfile'; see fetchLanguageNames()
747749 * @return string: Language name or empty
748750 * @since 1.20
749751 */
750 - public static function fetchLanguageName( $code, $inLanguage = null ) {
751 - $array = self::fetchLanguageNames( $inLanguage, 'all' );
 752+ public static function fetchLanguageName( $code, $inLanguage = null, $include = 'all' ) {
 753+ $array = self::fetchLanguageNames( $inLanguage, $include );
752754 return !array_key_exists( $code, $array ) ? '' : $array[$code];
753755 }
754756

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112479Combine getLanguageNames and getTranslatedLanguageNames into one function whi...robin11:59, 27 February 2012

Status & tagging log