ApiQuerySiteinfo: Use proper localised skin display names if available
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 29 Aug 2014 19:51:56 +0000 (21:51 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 15 Sep 2014 13:03:01 +0000 (13:03 +0000)
Based on the code in Preferences::generateSkinOptions(). This should
probably be turned into a helper method one day…

Bug: 48953
Change-Id: Ib85a783bd19de8a59e7b81a4203a05b786e67772

includes/api/ApiQuerySiteinfo.php

index 7414453..fd0c429 100644 (file)
@@ -696,6 +696,16 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $allowed = Skin::getAllowedSkins();
                $default = Skin::normalizeKey( 'default' );
                foreach ( Skin::getSkinNames() as $name => $displayName ) {
+                       $msg = $this->msg( "skinname-{$name}" );
+                       $code = $this->getParameter( 'inlanguagecode' );
+                       if ( $code && Language::isValidCode( $code ) ) {
+                               $msg->inLanguage( $code );
+                       } else {
+                               $msg->inContentLanguage();
+                       }
+                       if ( $msg->exists() ) {
+                               $displayName = $msg->text();
+                       }
                        $skin = array( 'code' => $name );
                        ApiResult::setContent( $skin, $displayName );
                        if ( !isset( $allowed[$name] ) ) {
@@ -849,7 +859,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' restrictions          - Returns information on available restriction (protection) types',
                                ' languages             - Returns a list of languages MediaWiki supports ' .
                                        "(optionally localised by using {$p}inlanguagecode)",
-                               ' skins                 - Returns a list of all enabled skins',
+                               ' skins                 - Returns a list of all enabled skins ' .
+                                       "(optionally localised by using {$p}inlanguagecode, otherwise in content language)",
                                ' extensiontags         - Returns a list of parser extension tags',
                                ' functionhooks         - Returns a list of parser function hooks',
                                ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)',
@@ -861,7 +872,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        'showalldb' => 'List all database servers, not just the one lagging the most',
                        'numberingroup' => 'Lists the number of users in user groups',
                        'inlanguagecode' => 'Language code for localised language names ' .
-                               '(best effort, use CLDR extension)',
+                               '(best effort, use CLDR extension) and skin names',
                );
        }