From 59a5f7e292e0fd723cd9094cb58c5dc2a2dbf591 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Mon, 11 Jul 2011 12:23:39 +0000 Subject: [PATCH] * (bug 16699) {{#language:}} accepts second parameter to specify the language in which the language name is wanted. Coverage depends on the cldr extension. --- RELEASE-NOTES-1.19 | 2 ++ includes/parser/CoreParserFunctions.php | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 6df9525246..240831c916 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -68,6 +68,8 @@ production. EditPage::showEditForm:initial * (bug 29723) mw.util.wikiGetlink() now defaults to wgPageName. * (bug 29680) Add GetDefaultSortkey hook to override the default sortkey. +* (bug 16699) {{#language:}} accepts second parameter to specify the language in + which the language name is wanted. Coverage depends on the cldr extension. === Bug fixes in 1.19 === * (bug 28868) Show total pages in the subtitle of an image on the diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 67abb10dfc..72534583f4 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -597,10 +597,18 @@ class CoreParserFunctions { return implode( $restrictions, ',' ); } - static function language( $parser, $arg = '' ) { + static function language( $parser, $code = '', $language = '' ) { global $wgContLang; - $lang = $wgContLang->getLanguageName( strtolower( $arg ) ); - return $lang != '' ? $lang : $arg; + $code = strtolower( $code ); + $language = strtolower( $language ); + + if ( $language !== '' ) { + $names = Language::getTranslatedLanguageNames( $language ); + return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code ); + } + + $lang = $wgContLang->getLanguageName( $code ); + return $lang !== '' ? $lang : wfBCP47( $code ); } /** -- 2.20.1