Add i18n for API module help

MediaWiki core change I04b1a384 added support for i18n of API module
help. This takes advantage of that while still maintaining backwards
compatibility with earlier versions of MediaWiki.

Once support for MediaWiki before 1.25 is dropped, the methods marked
deprecated in this patch may be removed.

Change-Id: I67395aff48185f3e09da31b51a08aa2541fe6a17
This commit is contained in:
Brad Jorsch 2014-10-29 11:57:35 -04:00
parent 108014ad6d
commit 48c47e1cf0
4 changed files with 101 additions and 27 deletions

View file

@ -88,10 +88,16 @@ class ApiQueryGadgetCategories extends ApiQueryBase {
);
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getDescription() {
return 'Returns a list of gadget categories';
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getParamDescription() {
return array(
'prop' => array(
@ -104,6 +110,9 @@ class ApiQueryGadgetCategories extends ApiQueryBase {
);
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getExamples() {
$params = $this->getAllowedParams();
$allProps = implode( '|', $params['prop'][ApiBase::PARAM_TYPE] );
@ -116,7 +125,15 @@ class ApiQueryGadgetCategories extends ApiQueryBase {
);
}
public function getVersion() {
return __CLASS__ . ': $Id$';
/**
* @see ApiBase::getExamplesMessages()
*/
protected function getExamplesMessages() {
return array(
'action=query&list=gadgetcategories'
=> 'apihelp-query+gadgetcategories-example-1',
'action=query&list=gadgetcategories&gcnames=foo|bar&gcprop=name|title|members'
=> 'apihelp-query+gadgetcategories-example-2',
);
}
}

View file

@ -186,10 +186,16 @@ class ApiQueryGadgets extends ApiQueryBase {
);
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getDescription() {
return 'Returns a list of gadgets used on this wiki';
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getParamDescription() {
return array(
'prop' => array(
@ -205,6 +211,9 @@ class ApiQueryGadgets extends ApiQueryBase {
);
}
/**
* @deprecated since MediaWiki core 1.25
*/
public function getExamples() {
$params = $this->getAllowedParams();
$allProps = implode( '|', $params['prop'][ApiBase::PARAM_TYPE] );
@ -222,7 +231,23 @@ class ApiQueryGadgets extends ApiQueryBase {
);
}
public function getVersion() {
return __CLASS__ . ': $Id$';
/**
* @see ApiBase::getExamplesMessages()
*/
protected function getExamplesMessages() {
$params = $this->getAllowedParams();
$allProps = implode( '|', $params['prop'][ApiBase::PARAM_TYPE] );
return array(
'action=query&list=gadgets&gaprop=id|desc'
=> 'apihelp-query+gadgets-example-1',
"action=query&list=gadgets&gaprop=$allProps"
=> 'apihelp-query+gadgets-example-2',
'action=query&list=gadgets&gacategories=foo'
=> 'apihelp-query+gadgets-example-3',
'action=query&list=gadgets&gaids=foo|bar&gaprop=id|desc|metadata'
=> 'apihelp-query+gadgets-example-4',
'action=query&list=gadgets&gaenabledonly'
=> 'apihelp-query+gadgets-example-5',
);
}
}

View file

@ -19,5 +19,21 @@
"gadgets-export-title": "Gadget export",
"gadgets-not-found": "Gadget \"$1\" not found.",
"gadgets-export-text": "To export the $1 gadget, click on \"{{int:gadgets-export-download}}\" button, save the downloaded file,\ngo to Special:Import on destination wiki and upload it. Then add the following to MediaWiki:Gadgets-definition page:\n<pre>$2</pre>\nYou must have appropriate permissions on destination wiki (including the right to edit system messages) and import from file uploads must be enabled.",
"gadgets-export-download": "Download"
"gadgets-export-download": "Download",
"apihelp-query+gadgetcategories-description": "Returns a list of gadget categories.",
"apihelp-query+gadgetcategories-param-prop": "What gadget category information to get:\n;name:Internal category name.\n;title:Category title.\n;members:Number of gadgets in category.",
"apihelp-query+gadgetcategories-param-names": "Names of categories to retrieve.",
"apihelp-query+gadgetcategories-example-1": "Get a list of existing gadget categories",
"apihelp-query+gadgetcategories-example-2": "Get all information about categories named \"foo\" and \"bar\"",
"apihelp-query+gadgets-description": "Returns a list of gadgets used on this wiki.",
"apihelp-query+gadgets-param-prop": "What gadget information to get:\n;id:Internal gadget ID.\n;metadata:The gadget metadata.\n;desc:Gadget description transformed into HTML (can be slow, use only if really needed).",
"apihelp-query+gadgets-param-categories": "Gadgets from what categories to retrieve.",
"apihelp-query+gadgets-param-ids": "IDs of gadgets to retrieve.",
"apihelp-query+gadgets-param-allowedonly": "List only gadgets allowed to current user.",
"apihelp-query+gadgets-param-enabledonly": "List only gadgets enabled by current user.",
"apihelp-query+gadgets-example-1": "Get a list of gadgets along with their descriptions",
"apihelp-query+gadgets-example-2": "Get a list of gadgets with all possible properties",
"apihelp-query+gadgets-example-3": "Get a list of gadgets belonging to category \"foo\"",
"apihelp-query+gadgets-example-4": "Get information about gadgets \"foo\" and \"bar\"",
"apihelp-query+gadgets-example-5": "Get a list of gadgets enabled by current user"
}

View file

@ -29,5 +29,21 @@
"gadgets-export-title": "Used as page title. Example: [[Special:Gadgets/export/editbuttons]]",
"gadgets-not-found": "Used as error message. Parameters:\n* $1 - gadget name",
"gadgets-export-text": "Used as page description in [[Special:Gadgets]].\n\nRefers to {{msg-mw|Gadgets-export-download}}.\n\nSee example: [[Special:Gadgets/export/editbuttons]]\n\nFollowed by the \"Export\" form.\n\nParameters:\n* $1 - gadget name\n* $2 - gadget definition (code)",
"gadgets-export-download": "Use the verb for this message. Submit button.\n{{Identical|Download}}"
"gadgets-export-download": "Use the verb for this message. Submit button.\n{{Identical|Download}}",
"apihelp-query+gadgetcategories-description": "{{doc-apihelp-description|query+gadgetcategories}}",
"apihelp-query+gadgetcategories-param-prop": "{{doc-apihelp-param|query+gadgetcategories|prop}}",
"apihelp-query+gadgetcategories-param-names": "{{doc-apihelp-param|query+gadgetcategories|names}}",
"apihelp-query+gadgetcategories-example-1": "{{doc-apihelp-example|query+gadgetcategories}}",
"apihelp-query+gadgetcategories-example-2": "{{doc-apihelp-example|query+gadgetcategories}}",
"apihelp-query+gadgets-description": "{{doc-apihelp-description|query+gadgets}}",
"apihelp-query+gadgets-param-prop": "{{doc-apihelp-param|query+gadgets|prop}}",
"apihelp-query+gadgets-param-categories": "{{doc-apihelp-param|query+gadgets|categories}}",
"apihelp-query+gadgets-param-ids": "{{doc-apihelp-param|query+gadgets|ids}}",
"apihelp-query+gadgets-param-allowedonly": "{{doc-apihelp-param|query+gadgets|allowedonly}}",
"apihelp-query+gadgets-param-enabledonly": "{{doc-apihelp-param|query+gadgets|enabledonly}}",
"apihelp-query+gadgets-example-1": "{{doc-apihelp-example|query+gadgets}}",
"apihelp-query+gadgets-example-2": "{{doc-apihelp-example|query+gadgets}}",
"apihelp-query+gadgets-example-3": "{{doc-apihelp-example|query+gadgets}}",
"apihelp-query+gadgets-example-4": "{{doc-apihelp-example|query+gadgets}}",
"apihelp-query+gadgets-example-5": "{{doc-apihelp-example|query+gadgets}}"
}