API: Include variant name in meta=siteinfo
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 27 Dec 2013 21:25:34 +0000 (16:25 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 27 Dec 2013 21:25:34 +0000 (16:25 -0500)
For languages with variants, we're already returning the list of variant
codes in meta=siteinfo&siprop=general. Clients may have use for the
variant's human-readable name too, and we can easily add it to the
datastructure.

Change-Id: I6c7ebf43a699a0b2346cb0fdeef6487217992f5c

includes/api/ApiQuerySiteinfo.php

index a94f5bb..697ae99 100644 (file)
@@ -199,7 +199,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                if ( $wgContLang->hasVariants() ) {
                        $variants = array();
                        foreach ( $wgContLang->getVariants() as $code ) {
-                               $variants[] = array( 'code' => $code );
+                               $variants[] = array(
+                                       'code' => $code,
+                                       'name' => $wgContLang->getVariantname( $code ),
+                               );
                        }
                        $data['variants'] = $variants;
                        $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );