From b539f7a98e5a58b96913b494f2526f45f134b9be Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Thu, 8 Mar 2012 19:30:30 +0000 Subject: [PATCH] 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.) --- includes/parser/Parser.php | 4 +--- languages/Language.php | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index de71d29abd..1be509c89c 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1901,11 +1901,9 @@ class Parser { # Link not escaped by : , create the various objects if ( $noforce ) { - global $wgContLang; - # Interwikis wfProfileIn( __METHOD__."-interwiki" ); - if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw ) ) { + if ( $iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName( $iw, null, 'mw' ) ) { $this->mOutput->addLanguageLink( $nt->getFullText() ); $s = rtrim( $s . $prefix ); $s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail; diff --git a/languages/Language.php b/languages/Language.php index 3a25dfcc77..854a9f1010 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -682,14 +682,15 @@ class Language { /** * Get an array of language names, indexed by code. * @param $inLanguage null|string: Code of language in which to return the names - * Use null for autonyms (native names) + * Use null for autonyms (native names) * @param $include string: * 'all' all available languages * 'mw' only if the language is defined in MediaWiki or wgExtraLanguageNames * 'mwfile' only if the language is in 'mw' *and* has a message file * @return array|bool: language code => language name, false if $include is wrong + * @since 1.20 */ - public static function fetchLanguageNames( $inLanguage = null, $include = 'all' ) { + public static function fetchLanguageNames( $inLanguage = null, $include = 'mw' ) { global $wgExtraLanguageNames; static $coreLanguageNames; @@ -743,11 +744,12 @@ class Language { /** * @param $code string: The code of the language for which to get the name * @param $inLanguage null|string: Code of language in which to return the name (null for autonyms) + * @param $include string: 'all', 'mw' or 'mwfile'; see fetchLanguageNames() * @return string: Language name or empty * @since 1.20 */ - public static function fetchLanguageName( $code, $inLanguage = null ) { - $array = self::fetchLanguageNames( $inLanguage, 'all' ); + public static function fetchLanguageName( $code, $inLanguage = null, $include = 'all' ) { + $array = self::fetchLanguageNames( $inLanguage, $include ); return !array_key_exists( $code, $array ) ? '' : $array[$code]; } -- 2.20.1