Sn1per has uploaded a new change for review.
https://gerrit.wikimedia.org/r/178080
Change subject: Convert API help to use i18n pt.3
......................................................................
Convert API help to use i18n pt.3
- API help modified to use i18n messages
- i18n messages edited to add said messages
Bug: T74704
Change-Id: I742729f002bd58a816a86b6137f7c5d68ab1915e
---
M repo/includes/api/GetClaims.php
M repo/includes/api/GetEntities.php
M repo/includes/api/LinkTitles.php
M repo/includes/api/MergeItems.php
M repo/includes/api/ParseValue.php
5 files changed, 61 insertions(+), 226 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/80/178080/1
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index 44d3723..67091c2 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -228,53 +228,20 @@
}
/**
- * @see \ApiBase::getParamDescription
- *
- * @since 0.3
+ * @see ApiBase:getExamplesMessages()
*
* @return array
*/
- public function getParamDescription() {
+ protected function getExamplesMessages() {
return array(
- 'entity' => 'Id of the entity from which to obtain
claims. Required unless claim GUID is provided.',
- 'property' => 'Optional filter to only return claims
with a main snak that has the specified property.',
- 'claim' => 'A GUID identifying the claim. Required
unless entity is provided. The GUID is the globally unique identifier for a
claim, e.g. "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F".',
- 'rank' => 'Optional filter to return only the claims
that have the specified rank',
- 'props' => 'Some parts of the claim are returned
optionally. This parameter controls which ones are returned.',
- 'ungroupedlist' => 'Do not group snaks by property id',
- );
- }
-
- /**
- * @see \ApiBase::getDescription
- *
- * @since 0.3
- *
- * @return string
- */
- public function getDescription() {
- return array(
- 'API module for getting Wikibase claims.'
- );
- }
-
- /**
- * @see \ApiBase::getExamples
- *
- * @since 0.3
- *
- * @return array
- */
- protected function getExamples() {
- return array(
- "api.php?action=wbgetclaims&entity=Q42" =>
- "Get claims for item with ID Q42",
- "api.php?action=wbgetclaims&entity=Q42&property=P2" =>
- "Get claims for item with ID Q42 and property
with ID P2",
- "api.php?action=wbgetclaims&entity=Q42&rank=normal" =>
- "Get claims for item with ID Q42 that are
ranked as normal",
-
'api.php?action=wbgetclaims&claim=Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F' =>
- 'Get claim with GUID of
Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F',
+ "action=wbgetclaims&entity=Q42" =>
+ "apihelp-wbgetclaims-example-1",
+ "action=wbgetclaims&entity=Q42&property=P2" =>
+ "apihelp-wbgetclaims-example-2",
+ "action=wbgetclaims&entity=Q42&rank=normal" =>
+ "apihelp-wbgetclaims-example-3",
+
'action=wbgetclaims&claim=Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F' =>
+ 'apihelp-wbgetclaims-example-4',
);
}
diff --git a/repo/includes/api/GetEntities.php
b/repo/includes/api/GetEntities.php
index f8eacb6..dbfae7a 100644
--- a/repo/includes/api/GetEntities.php
+++ b/repo/includes/api/GetEntities.php
@@ -342,77 +342,38 @@
}
/**
- * @see ApiBase::getParamDescription()
+ * @see ApiBase:getExamplesMessages()
+ *
+ * @return array
*/
- public function getParamDescription() {
- return array_merge( parent::getParamDescription(), array(
- 'ids' => 'The IDs of the entities to get the data from',
- 'sites' => array( 'Identifier for the site on which the
corresponding page resides',
- "Use together with 'title', but only give one
site for several titles or several sites for one title."
- ),
- 'titles' => array( 'The title of the corresponding
page',
- "Use together with 'sites', but only give one
site for several titles or several sites for one title."
- ),
- 'redirects' => array( 'Whether redirects shall be
resolved.',
- 'If set to "no", redirects will be treated like
deleted entities.'
- ),
- 'props' => array( 'The names of the properties to get
back from each entity.',
- "Will be further filtered by any languages
given."
- ),
- 'languages' => array( 'By default the internationalized
values are returned in all available languages.',
- 'This parameter allows filtering these down to
one or more languages by providing one or more language codes.'
- ),
- 'languagefallback' => array( 'Apply language fallback
for languages defined in the "languages" parameter,',
- 'with the current context of API call.'
- ),
- 'normalize' => array( 'Try to normalize the page title
against the client site.',
- 'This only works if exactly one site and one
page have been given.'
- ),
- 'ungroupedlist' => array( 'Do not group snaks by
property id.' ),
- 'sitefilter' => array( 'Filter sitelinks in entities to
those with these siteids.' ),
- ) );
- }
-
- /**
- * @see ApiBase::getDescription()
- */
- public function getDescription() {
+ protected function getExamplesMessages() {
return array(
- 'API module to get the data for multiple Wikibase
entities.'
- );
- }
-
- /**
- * @see ApiBase::getExamples()
- */
- protected function getExamples() {
- return array(
- "api.php?action=wbgetentities&ids=Q42"
- => "Get entities with ID Q42 with all available
attributes in all available languages",
- "api.php?action=wbgetentities&ids=P17"
- => "Get entities with ID P17 with all available
attributes in all available languages",
- "api.php?action=wbgetentities&ids=Q42|P17"
- => "Get entities with IDs Q42 and P17 with all
available attributes in all available languages",
- "api.php?action=wbgetentities&ids=Q42&languages=en"
- => "Get entities with ID Q42 with all available
attributes in English language",
-
"api.php?action=wbgetentities&ids=Q42&languages=ii&languagefallback="
- => "Get entities with ID Q42 with all available
attributes in any possible fallback language for the ii language",
- "api.php?action=wbgetentities&ids=Q42&props=labels"
- => "Get entities with ID Q42 showing all labels in all
available languages",
- "api.php?action=wbgetentities&ids=P17|P3&props=datatype"
- => "Get entities with IDs P17 and P3 showing only
datatypes",
-
"api.php?action=wbgetentities&ids=Q42&props=aliases&languages=en"
- => "Get entities with ID Q42 showing all aliases in
English language",
-
"api.php?action=wbgetentities&ids=Q1|Q42&props=descriptions&languages=en|de|fr"
- => "Get entities with IDs Q1 and Q42 showing
descriptions in English, German and French languages",
-
'api.php?action=wbgetentities&sites=enwiki&titles=Berlin&languages=en'
- => 'Get the item for page "Berlin" on the site
"enwiki", with language attributes in English language',
-
'api.php?action=wbgetentities&sites=enwiki&titles=berlin&normalize='
- => 'Get the item for page "Berlin" on the site "enwiki"
after normalizing the title from "berlin"',
- 'api.php?action=wbgetentities&ids=Q42&props=sitelinks'
- => 'Get the sitelinks for item Q42',
- 'api.php?action=wbgetentities&ids=Q42&sitefilter=enwiki'
- => 'Get entities with ID Q42 showing only sitelinks
from enwiki'
+ "action=wbgetentities&ids=Q42"
+ => "apihelp-wbgetentities-example-1",
+ "action=wbgetentities&ids=P17"
+ => "apihelp-wbgetentities-example-2",
+ "action=wbgetentities&ids=Q42|P17"
+ => "apihelp-wbgetentities-example-3",
+ "action=wbgetentities&ids=Q42&languages=en"
+ => "apihelp-wbgetentities-example-4",
+
"action=wbgetentities&ids=Q42&languages=ii&languagefallback="
+ => "apihelp-wbgetentities-example-5",
+ "action=wbgetentities&ids=Q42&props=labels"
+ => "apihelp-wbgetentities-example-6",
+ "action=wbgetentities&ids=P17|P3&props=datatype"
+ => "apihelp-wbgetentities-example-7",
+
"action=wbgetentities&ids=Q42&props=aliases&languages=en"
+ => "apihelp-wbgetentities-example-8",
+
"action=wbgetentities&ids=Q1|Q42&props=descriptions&languages=en|de|fr"
+ => "apihelp-wbgetentities-example-9",
+
'action=wbgetentities&sites=enwiki&titles=Berlin&languages=en'
+ => 'apihelp-wbgetentities-example-10',
+
'action=wbgetentities&sites=enwiki&titles=berlin&normalize='
+ => 'apihelp-wbgetentities-example-11',
+ 'action=wbgetentities&ids=Q42&props=sitelinks'
+ => 'apihelp-wbgetentities-example-12',
+ 'action=wbgetentities&ids=Q42&sitefilter=enwiki'
+ => 'apihelp-wbgetentities-example-13'
);
}
diff --git a/repo/includes/api/LinkTitles.php b/repo/includes/api/LinkTitles.php
index 84c91cd..baff0e5 100644
--- a/repo/includes/api/LinkTitles.php
+++ b/repo/includes/api/LinkTitles.php
@@ -237,50 +237,14 @@
}
/**
- * Get final parameter descriptions, after hooks have had a chance to
tweak it as
- * needed.
+ * @see ApiBase:getExamplesMessages()
*
- * @return array|bool False on no parameter descriptions
+ * @return array
*/
- public function getParamDescription() {
- return array_merge( parent::getParamDescription(), array(
- 'tosite' => array( 'An identifier for the site on which
the page resides.',
- "Use together with 'totitle' to make a complete
sitelink."
- ),
- 'totitle' => array( 'Title of the page to associate.',
- "Use together with 'tosite' to make a complete
sitelink."
- ),
- 'fromsite' => array( 'An identifier for the site on
which the page resides.',
- "Use together with 'fromtitle' to make a
complete sitelink."
- ),
- 'fromtitle' => array( 'Title of the page to associate.',
- "Use together with 'fromsite' to make a
complete sitelink."
- ),
- 'token' => 'A "edittoken" token previously obtained
through the token module (prop=info).',
- 'bot' => array( 'Mark this edit as bot',
- 'This URL flag will only be respected if the
user belongs to the group "bot".'
- ),
- ) );
- }
-
- /**
- * Returns the description string for this module
- * @return mixed string or array of strings
- */
- public function getDescription() {
+ protected function getExamplesMessages() {
return array(
- 'API module to associate two articles on two different
wikis with a Wikibase item.'
- );
- }
-
- /**
- * Returns usage examples for this module. Return false if no examples
are available.
- * @return bool|string|array
- */
- protected function getExamples() {
- return array(
-
'api.php?action=wblinktitles&fromsite=enwiki&fromtitle=Hydrogen&tosite=dewiki&totitle=Wasserstoff'
- => 'Add a link "Hydrogen" from the English page to
"Wasserstoff" at the German page',
+
'action=wblinktitles&fromsite=enwiki&fromtitle=Hydrogen&tosite=dewiki&totitle=Wasserstoff'
+ => 'apihelp-wblinktitles-example-1',
);
}
diff --git a/repo/includes/api/MergeItems.php b/repo/includes/api/MergeItems.php
index 9d4dab6..831f982 100644
--- a/repo/includes/api/MergeItems.php
+++ b/repo/includes/api/MergeItems.php
@@ -204,47 +204,20 @@
}
/**
- * @see ApiBase::getParamDescription
+ * @see ApiBase:getExamplesMessages()
+ *
+ * @return array
*/
- public function getParamDescription() {
+ protected function getExamplesMessages() {
return array(
- 'fromid' => array( 'The id to merge from' ),
- 'toid' => array( 'The id to merge to' ),
- 'ignoreconflicts' => array( 'Array of elements of the
item to ignore conflicts for, can only contain values of "label" and or
"description" and or "sitelink"' ),
- 'token' => 'An "edittoken" token previously obtained
through the token module (prop=info).',
- 'summary' => array( 'Summary for the edit.',
- "Will be prepended by an automatically
generated comment. The length limit of the
- autocomment together with the summary is 260
characters. Be aware that everything above that
- limit will be cut off."
- ),
- 'bot' => array( 'Mark this edit as bot',
- 'This URL flag will only be respected if the
user belongs to the group "bot".'
- ),
- );
- }
-
- /**
- * @see ApiBase::getDescription
- */
- public function getDescription() {
- return array(
- 'API module to merge multiple items.'
- );
- }
-
- /**
- * @see ApiBase::getExamples
- */
- protected function getExamples() {
- return array(
- 'api.php?action=wbmergeitems&fromid=Q42&toid=Q222' =>
- 'Merges data from Q42 into Q222',
- 'api.php?action=wbmergeitems&fromid=Q555&toid=Q3' =>
- 'Merges data from Q555 into Q3',
-
'api.php?action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=label' =>
- 'Merges data from Q66 into Q99 ignoring any
conflicting labels',
-
'api.php?action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=label|description'
=>
- 'Merges data from Q66 into Q99 ignoring any
conflicting labels and descriptions',
+ 'action=wbmergeitems&fromid=Q42&toid=Q222' =>
+ 'apihelp-wbmergeitems-example-1',
+ 'action=wbmergeitems&fromid=Q555&toid=Q3' =>
+ 'apihelp-wbmergeitems-example-2',
+
'action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=label' =>
+ 'apihelp-wbmergeitems-example-3',
+
'action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=label|description' =>
+ 'apihelp-wbmergeitems-example-4',
);
}
diff --git a/repo/includes/api/ParseValue.php b/repo/includes/api/ParseValue.php
index 191bf7d..622a44d 100644
--- a/repo/includes/api/ParseValue.php
+++ b/repo/includes/api/ParseValue.php
@@ -173,44 +173,14 @@
}
/**
- * @see ApiBase::getParamDescription
- *
- * @since 0.1
+ * @see ApiBase:getExamplesMessages()
*
* @return array
*/
- public function getParamDescription() {
+ protected function getExamplesMessages() {
return array(
- 'parser' => 'Id of the ValueParser to use',
- 'values' => 'The values to parse',
- 'options' => 'The options the parser should use.
Provided as a JSON object.',
- );
- }
-
- /**
- * @see ApiBase::getDescription
- *
- * @since 0.1
- *
- * @return string
- */
- public function getDescription() {
- return array(
- 'API module for parsing values using a ValueParser.'
- );
- }
-
- /**
- * @see ApiBase::getExamples
- *
- * @since 0.1
- *
- * @return array
- */
- protected function getExamples() {
- return array(
-
'api.php?action=wbparsevalue&parser=null&values=foo|bar' => 'No change to the
format of the string.',
-
'api.php?action=wbparsevalue&parser=time&values=1994-02-08&options={"precision":9}'
=> 'Parse 1994-02-08 to a date format with a precision of 9 (the year).',
+ 'action=wbparsevalue&parser=null&values=foo|bar' =>
'apihelp-wbparsevalue-example-1',
+
'action=wbparsevalue&parser=time&values=1994-02-08&options={"precision":9}' =>
'apihelp-wbparsevalue-example-2',
);
}
--
To view, visit https://gerrit.wikimedia.org/r/178080
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I742729f002bd58a816a86b6137f7c5d68ab1915e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Sn1per <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits