From eaf78d51d3c2798f8f311cc8479a3e44109366f4 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 5 Aug 2011 13:34:22 +0000 Subject: [PATCH] * (bug 18634) Create API to fetch MediaWiki's language fallback tree structure Patch by "merl" Tested with pt-br, seems to work fine, listing pt and en for the fallback languages --- CREDITS | 1 + RELEASE-NOTES-1.19 | 1 + includes/api/ApiQuerySiteinfo.php | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/CREDITS b/CREDITS index db1aec0414..3e869617b8 100644 --- 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. diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 5b4e384820..6827008bbc 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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 === diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 328decbae8..4749610eb7 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -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'] = ''; } -- 2.20.1