r93314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93313‎ | r93314 | r93315 >
Date:21:16, 27 July 2011
Author:siebrand
Status:ok (Comments)
Tags:
Comment:
siprop=interwikimap and siprop=languages can now use silanguagecode to have a best effort language name translation. Use CLDR extension for best result.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -31,10 +31,11 @@
3232
3333 === API changes in 1.19 ===
3434 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
35 -* (bug 29748) Add API search prefix support
36 -* (bug 29684) Set forgotten parameter types in ApiQueryIWLinks
37 -* (bug 29685) do not output NULL parentid with
38 - list=deletedrevs&drprop=parentid
 35+* (bug 29748) Add API search prefix support.
 36+* (bug 29684) Set forgotten parameter types in ApiQueryIWLinks.
 37+* (bug 29685) do not output NULL parentid with list=deletedrevs&drprop=parentid.
 38+* siprop=interwikimap and siprop=languages can use silanguagecode to have
 39+ a best effort language name translation. Use CLDR extension for best result.
3940
4041 === Languages updated in 1.19 ===
4142
Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -265,9 +265,18 @@
266266 ApiBase::dieDebug( __METHOD__, "Unknown filter=$filter" );
267267 }
268268
 269+ $params = $this->extractRequestParams();
 270+ $langCode = isset( $params['languagecode'] ) ? $params['languagecode'] : '';
 271+
 272+ if( $langCode ) {
 273+ $langNames = Language::getTranslatedLanguageNames( $langCode );
 274+ } else {
 275+ $langNames = Language::getLanguageNames();
 276+ }
 277+
269278 $getPrefixes = Interwiki::getAllPrefixes( $local );
270279 $data = array();
271 - $langNames = Language::getLanguageNames();
 280+
272281 foreach ( $getPrefixes as $row ) {
273282 $prefix = $row['iw_prefix'];
274283 $val = array();
@@ -462,8 +471,18 @@
463472 }
464473
465474 public function appendLanguages( $property ) {
 475+ $params = $this->extractRequestParams();
 476+ $langCode = isset( $params['languagecode'] ) ? $params['languagecode'] : '';
 477+
 478+ if( $langCode ) {
 479+ $langNames = Language::getTranslatedLanguageNames( $langCode );
 480+ } else {
 481+ $langNames = Language::getLanguageNames();
 482+ }
 483+
466484 $data = array();
467 - foreach ( Language::getLanguageNames() as $code => $name ) {
 485+
 486+ foreach ( $langNames as $code => $name ) {
468487 $lang = array( 'code' => $code );
469488 ApiResult::setContent( $lang, $name );
470489 $data[] = $lang;
@@ -560,6 +579,7 @@
561580 ),
562581 'showalldb' => false,
563582 'numberingroup' => false,
 583+ 'languagecode' => null,
564584 );
565585 }
566586
@@ -573,13 +593,13 @@
574594 ' specialpagealiases - List of special page aliases',
575595 ' magicwords - List of magic words and their aliases',
576596 ' statistics - Returns site statistics',
577 - ' interwikimap - Returns interwiki map (optionally filtered)',
 597+ ' interwikimap - Returns interwiki map (optionally filtered, (optionally localised))',
578598 ' dbrepllag - Returns database server with the highest replication lag',
579599 ' usergroups - Returns user groups and the associated permissions',
580600 ' extensions - Returns extensions installed on the wiki',
581601 ' fileextensions - Returns list of file extensions allowed to be uploaded',
582602 ' rightsinfo - Returns wiki rights (license) information if available',
583 - ' languages - Returns a list of languages MediaWiki supports',
 603+ ' languages - Returns a list of languages MediaWiki supports (optionally localised)',
584604 ' skins - Returns a list of all enabled skins',
585605 ' extensiontags - Returns a list of parser extension tags',
586606 ' functionhooks - Returns a list of parser function hooks',
@@ -588,6 +608,7 @@
589609 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
590610 'showalldb' => 'List all database servers, not just the one lagging the most',
591611 'numberingroup' => 'Lists the number of users in user groups',
 612+ 'languagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
592613 );
593614 }
594615

Sign-offs

UserFlagDate
Reedyinspected10:17, 28 July 2011
Reedytested10:17, 28 July 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r93765Fix minor naming issue from r93314, add a bit to parameter documentation alsoreedy16:26, 2 August 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:44, 28 July 2011

Could we come up with something more descriptive? Language code could be basically for anything. How about inlanguage or translateto or translationlanguagecode?

#Comment by Reedy (talk | contribs)   10:07, 28 July 2011

inlanguagecode might work, but I do agree language code is slightly vague.

Might be worth adding to the "(optionally localised)" something like "by using whatevertheparameternamegetschangedto"

#Comment by Reedy (talk | contribs)   10:17, 28 July 2011

Other than that, this sees fine for me (I just tested it)

Status & tagging log