* (bug 16699) {{#language:}} accepts second parameter to specify the language in
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Mon, 11 Jul 2011 12:23:39 +0000 (12:23 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Mon, 11 Jul 2011 12:23:39 +0000 (12:23 +0000)
  which the language name is wanted. Coverage depends on the cldr extension.

RELEASE-NOTES-1.19
includes/parser/CoreParserFunctions.php

index 6df9525..240831c 100644 (file)
@@ -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
index 67abb10..7253458 100644 (file)
@@ -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 );
        }
 
        /**