C. Scott Ananian has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/340373 )
Change subject: T153341: Export list of languages which will trigger language
conversion.
......................................................................
T153341: Export list of languages which will trigger language conversion.
LanguageConverter is enabled on a per-page basis, based on the page
language and whether it implements `$lang->getConverter()`. Export
this in siteinfo so that Parsoid knows whether it should parse
language converter markup on a given page (based on the page language).
Change-Id: I010aa3812051725166ab79ea5ee3eaf56615fe94
---
M includes/api/ApiQuerySiteinfo.php
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
3 files changed, 43 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/73/340373/1
diff --git a/includes/api/ApiQuerySiteinfo.php
b/includes/api/ApiQuerySiteinfo.php
index a8c037e..0af303e 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -88,6 +88,9 @@
case 'languages':
$fit = $this->appendLanguages( $p );
break;
+ case 'variants':
+ $fit = $this->appendVariants( $p );
+ break;
case 'skins':
$fit = $this->appendSkins( $p );
break;
@@ -713,6 +716,43 @@
return $this->getResult()->addValue( 'query', $property, $data
);
}
+ // Export information about which page languages will trigger
+ // language conversion. (T153341)
+ public function appendVariants( $property ) {
+
+ global $wgDisableLangConversion;
+ $langNames = LanguageConverter::$languagesWithVariants;
+ sort( $langNames );
+
+ $data = [];
+ foreach ( $langNames as $langCode ) {
+ $lang = Language::factory( $langCode );
+ if (
+ $wgDisableLangConversion ||
+ $lang->getConverter() instanceof FakeConverter
+ ) {
+ // Only languages which are not instances of
FakeConverter
+ // implement language conversion.
+ continue;
+ }
+ $data[$langCode] = [];
+ ApiResult::setIndexedTagName( $data[$langCode],
'variant' );
+
+ $variants = $lang->getVariants();
+ sort( $variants );
+ foreach ( $variants as $v ) {
+ if ( $v === $langCode ) {
+ continue;
+ }
+ $data[$langCode][] = $v;
+ }
+ }
+ ApiResult::setIndexedTagName( $data, 'lang' );
+ ApiResult::setArrayType( $data, 'kvp', 'code' );
+
+ return $this->getResult()->addValue( 'query', $property, $data
);
+ }
+
public function appendSkins( $property ) {
$data = [];
$allowed = Skin::getAllowedSkins();
@@ -851,6 +891,7 @@
'rightsinfo',
'restrictions',
'languages',
+ 'variants',
'skins',
'extensiontags',
'functionhooks',
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index f9de725..fc2dedc 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -1139,6 +1139,7 @@
"apihelp-query+siteinfo-paramvalue-prop-rightsinfo": "Returns wiki
rights (license) information if available.",
"apihelp-query+siteinfo-paramvalue-prop-restrictions": "Returns
information on available restriction (protection) types.",
"apihelp-query+siteinfo-paramvalue-prop-languages": "Returns a list of
languages MediaWiki supports (optionally localised by using
<var>$1inlanguagecode</var>).",
+ "apihelp-query+siteinfo-paramvalue-prop-variants": "Returns a list of
languages for which [[mw:LanguageConverter|LanguageConverter]] is enabled, and
the variants supported for each.",
"apihelp-query+siteinfo-paramvalue-prop-skins": "Returns a list of all
enabled skins (optionally localised by using <var>$1inlanguagecode</var>,
otherwise in the content language).",
"apihelp-query+siteinfo-paramvalue-prop-extensiontags": "Returns a list
of parser extension tags.",
"apihelp-query+siteinfo-paramvalue-prop-functionhooks": "Returns a list
of parser function hooks.",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index d4380c2..e1e844b 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -1064,6 +1064,7 @@
"apihelp-query+siteinfo-paramvalue-prop-rightsinfo":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|rightsinfo}}",
"apihelp-query+siteinfo-paramvalue-prop-restrictions":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|restrictions}}",
"apihelp-query+siteinfo-paramvalue-prop-languages":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|languages}}",
+ "apihelp-query+siteinfo-paramvalue-prop-variants":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|variants}}",
"apihelp-query+siteinfo-paramvalue-prop-skins":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|skins}}",
"apihelp-query+siteinfo-paramvalue-prop-extensiontags":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|extensiontags}}",
"apihelp-query+siteinfo-paramvalue-prop-functionhooks":
"{{doc-apihelp-paramvalue|query+siteinfo|prop|functionhooks}}",
--
To view, visit https://gerrit.wikimedia.org/r/340373
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I010aa3812051725166ab79ea5ee3eaf56615fe94
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: C. Scott Ananian <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits