r91875 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91874‎ | r91875 | r91876 >
Date:12:23, 11 July 2011
Author:nikerabbit
Status:resolved (Comments)
Tags:
Comment:
* (bug 16699) {{#language:}} accepts second parameter to specify the language in
which the language name is wanted. Coverage depends on the cldr extension.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -68,6 +68,8 @@
6969 EditPage::showEditForm:initial
7070 * (bug 29723) mw.util.wikiGetlink() now defaults to wgPageName.
7171 * (bug 29680) Add GetDefaultSortkey hook to override the default sortkey.
 72+* (bug 16699) {{#language:}} accepts second parameter to specify the language in
 73+ which the language name is wanted. Coverage depends on the cldr extension.
7274
7375 === Bug fixes in 1.19 ===
7476 * (bug 28868) Show total pages in the subtitle of an image on the
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -597,10 +597,18 @@
598598 return implode( $restrictions, ',' );
599599 }
600600
601 - static function language( $parser, $arg = '' ) {
 601+ static function language( $parser, $code = '', $language = '' ) {
602602 global $wgContLang;
603 - $lang = $wgContLang->getLanguageName( strtolower( $arg ) );
604 - return $lang != '' ? $lang : $arg;
 603+ $code = strtolower( $code );
 604+ $language = strtolower( $language );
 605+
 606+ if ( $language !== '' ) {
 607+ $names = Language::getTranslatedLanguageNames( $language );
 608+ return isset( $names[$code] ) ? $names[$code] : wfBCP47( $code );
 609+ }
 610+
 611+ $lang = $wgContLang->getLanguageName( $code );
 612+ return $lang !== '' ? $lang : wfBCP47( $code );
605613 }
606614
607615 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r91892ping r91875nikerabbit18:05, 11 July 2011

Comments

#Comment by Siebrand (talk | contribs)   17:25, 11 July 2011

Please add parameter documentation for "language()".

#Comment by Siebrand (talk | contribs)   17:58, 11 July 2011

Then either add that URL/rev to the source code, or document it in the source code, too?

#Comment by Nikerabbit (talk | contribs)   18:04, 11 July 2011

I fail to see the point of documenting that function. It's only called by the parser.

Status & tagging log