* (bug 18634) Create API to fetch MediaWiki's language fallback tree structure
authorSam Reed <reedy@users.mediawiki.org>
Fri, 5 Aug 2011 13:34:22 +0000 (13:34 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 5 Aug 2011 13:34:22 +0000 (13:34 +0000)
Patch by "merl"

Tested with pt-br, seems to work fine, listing pt and en for the fallback languages

CREDITS
RELEASE-NOTES-1.19
includes/api/ApiQuerySiteinfo.php

diff --git a/CREDITS b/CREDITS
index db1aec0..3e86961 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -122,6 +122,7 @@ following names for their contribution to the product.
 * Matthew Britton
 * mati
 * Max Sikström
+* merl
 * Michael Dale
 * Michael De La Rue
 * Michael M.
index 5b4e384..6827008 100644 (file)
@@ -45,6 +45,7 @@ production.
 * siprop=interwikimap and siprop=languages can use silanguagecode to have
   a best effort language name translation. Use CLDR extension for best result.
 * (bug 30230) action=expandtemplates should not silently override invalid title inputs
+* (bug 18634) Create API to fetch MediaWiki's language fallback tree structure
 
 === Languages updated in 1.19 ===
 
index 328decb..4749610 100644 (file)
@@ -138,6 +138,16 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
                $data['rights'] = $GLOBALS['wgRightsText'];
                $data['lang'] = $GLOBALS['wgLanguageCode'];
+
+               $fallbackLang = $wgContLang->getFallbackLanguageCode();
+               $fallbackLangArray = array();
+               while( $fallbackLang ) {
+                       $fallbackLangArray[] = array( 'code' => $fallbackLang );
+                       $fallbackLang = Language::getFallbackFor( $fallbackLang );
+               }
+               $data['fallback'] = $fallbackLangArray;
+               $this->getResult()->setIndexedTagName( $data['fallback'], 'lang' );
+
                if ( $wgContLang->isRTL() ) {
                        $data['rtl'] = '';
                }