Sn1per has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/178079

Change subject: Convert API help to use i18n pt.2
......................................................................

Convert API help to use i18n pt.2

 - API help modified to use i18n messages
 - i18n messages edited to add said messages

Bug: T74704
Change-Id: Idc831fd2dcd9c6b2f69d9d3c6608e9bb7ba1be43
---
M repo/includes/api/AvailableBadges.php
M repo/includes/api/CreateClaim.php
M repo/includes/api/CreateRedirectModule.php
M repo/includes/api/EditEntity.php
M repo/includes/api/FormatSnakValue.php
5 files changed, 50 insertions(+), 175 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/79/178079/1

diff --git a/repo/includes/api/AvailableBadges.php 
b/repo/includes/api/AvailableBadges.php
index 1437c5c..e25c3ea 100644
--- a/repo/includes/api/AvailableBadges.php
+++ b/repo/includes/api/AvailableBadges.php
@@ -33,29 +33,14 @@
        }
 
        /**
-        * @see ApiBase::getDescription
-        *
-        * @since 0.5
-        *
-        * @return string
-        */
-       public function getDescription() {
-               return array(
-                       'API module to query available badge items.'
-               );
-       }
-
-       /**
-        * @see ApiBase::getExamples
-        *
-        * @since 0.5
+        * @see ApiBase:getExamplesMessages()
         *
         * @return array
         */
-       protected function getExamples() {
+       protected function getExamplesMessages() {
                return array(
-                       'api.php?action=wbavailablebadges' =>
-                               'Queries all available badge items',
+                       'action=wbavailablebadges' =>
+                               'apihelp-wbavailablebadges-example-1',
                );
        }
 
diff --git a/repo/includes/api/CreateClaim.php 
b/repo/includes/api/CreateClaim.php
index c5fe556..1930ad8 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -137,42 +137,20 @@
        }
 
        /**
-        * @see \ApiBase::getParamDescription
+        * @see ApiBase:getExamplesMessages()
+        *
+        * @return array
         */
-       public function getParamDescription() {
-               return array_merge(
-                       parent::getParamDescription(),
-                       array(
-                               'entity' => 'Id of the entity you are adding 
the claim to',
-                               'property' => 'Id of the snaks property',
-                               'value' => 'Value of the snak when creating a 
claim with a snak that has a value',
-                               'snaktype' => 'The type of the snak',
-                       )
-               );
-       }
-
-       /**
-        * @see \ApiBase::getDescription
-        */
-       public function getDescription() {
+       protected function getExamplesMessages() {
                return array(
-                       'API module for creating Wikibase claims.'
-               );
-       }
-
-       /**
-        * @see \ApiBase::getExamples
-        */
-       protected function getExamples() {
-               return array(
-                       
'api.php?action=wbcreateclaim&entity=Q42&property=P9001&snaktype=novalue'
-                               =>'Creates a claim for item Q42 of property 
P9001 with a novalue snak.',
-                       
'api.php?action=wbcreateclaim&entity=Q42&property=P9002&snaktype=value&value="itsastring"'
-                               => ' Creates a claim for item Q42 of property 
P9002 with string value "itsastring"',
-                       
'api.php?action=wbcreateclaim&entity=Q42&property=P9003&snaktype=value&value={"entity-type":"item","numeric-id":1}'
-                               => 'Creates a claim for item Q42 of property 
P9003 with a value of item Q1',
-                       
'api.php?action=wbcreateclaim&entity=Q42&property=P9004&snaktype=value&value={"latitude":40.748433,"longitude":-73.985656,"globe":"http://www.wikidata.org/entity/Q2","precision":0.000001}'
-                               => 'Creates a claim for item Q42 of property 
P9004 with a coordinate snak value',
+                       
'action=wbcreateclaim&entity=Q42&property=P9001&snaktype=novalue'
+                               =>'apihelp-wbcreateclaim-example-1',
+                       
'action=wbcreateclaim&entity=Q42&property=P9002&snaktype=value&value="itsastring"'
+                               => 'apihelp-wbcreateclaim-example-2',
+                       
'action=wbcreateclaim&entity=Q42&property=P9003&snaktype=value&value={"entity-type":"item","numeric-id":1}'
+                               => 'apihelp-wbcreateclaim-example-3',
+                       
'action=wbcreateclaim&entity=Q42&property=P9004&snaktype=value&value={"latitude":40.748433,"longitude":-73.985656,"globe":"http://www.wikidata.org/entity/Q2","precision":0.000001}'
+                               => 'apihelp-wbcreateclaim-example-4',
                );
        }
 }
diff --git a/repo/includes/api/CreateRedirectModule.php 
b/repo/includes/api/CreateRedirectModule.php
index 8dca3e3..039ea24 100644
--- a/repo/includes/api/CreateRedirectModule.php
+++ b/repo/includes/api/CreateRedirectModule.php
@@ -177,40 +177,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() {
+       protected function getExamplesMessages() {
                return array(
-                       'from' => array( 'Entity ID to make a redirect' ),
-                       'to' => array( 'Entity ID to point the redirect to' ),
-                       'token' => 'A "edittoken" token previously obtained 
through the token module',
-                       '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() {
-               return array(
-                       'API module for creating Entity redirects.'
-               );
-       }
-
-       /**
-        * 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=wbcreateredirect&from=Q11&to=Q12'
-                               => 'Turn Q11 into a redirect to Q12',
+                       'action=wbcreateredirect&from=Q11&to=Q12'
+                               => 'apihelp-wbcreateredirect-example-1',
                );
        }
 
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 67e3904..3f14b65 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -733,66 +733,35 @@
        }
 
        /**
-        * @see ApiBase::getParamDescription
+        * @see ApiBase:getExamplesMessages()
+        *
+        * @return array
         */
-       public function getParamDescription() {
-               return array_merge(
-                       parent::getParamDescription(),
-                       parent::getParamDescriptionForId(),
-                       parent::getParamDescriptionForSiteLink(),
-                       parent::getParamDescriptionForEntity(),
-                       array(
-                               'data' => array( 'The serialized object that is 
used as the data source.',
-                                       "A newly created entity will be 
assigned an 'id'."
-                               ),
-                               'clear' => array( 'If set, the complete entity 
is emptied before proceeding.',
-                                       'The entity will not be saved before it 
is filled with the "data", possibly with parts excluded.'
-                               ),
-                               'new' => array( "If set, a new entity will be 
created.",
-                                       "Set this to the type of the entity you 
want to create - currently 'item'|'property'.",
-                                       "It is not allowed to have this set 
when 'id' is also set."
-                               ),
-                       )
-               );
-       }
-
-       /**
-        * @see ApiBase::getDescription
-        */
-       public function getDescription() {
-               return array(
-                       'API module to create a single new Wikibase entity and 
modify it with serialised information.'
-               );
-       }
-
-       /**
-        * @see ApiBase::getExamples
-        */
-       protected function getExamples() {
+       protected function getExamplesMessages() {
                return array(
                        // Creating new entites
-                       'api.php?action=wbeditentity&new=item&data={}'
-                       => 'Create a new empty item, return full entity 
structure',
-                       
'api.php?action=wbeditentity&new=item&data={"labels":{"de":{"language":"de","value":"de-value"},"en":{"language":"en","value":"en-value"}}}'
-                       => 'Create a new item and set labels for de and en',
-                       
'api.php?action=wbeditentity&new=property&data={"labels":{"en-gb":{"language":"en-gb","value":"Propertylabel"}},"descriptions":{"en-gb":{"language":"en-gb","value":"Propertydescription"}},"datatype":"string"}'
-                       => 'Create a new property containing the json data, 
returns extended with the item structure',
+                       'action=wbeditentity&new=item&data={}'
+                       => 'apihelp-wbeditentity-example-1',
+                       
'action=wbeditentity&new=item&data={"labels":{"de":{"language":"de","value":"de-value"},"en":{"language":"en","value":"en-value"}}}'
+                       => 'apihelp-wbeditentity-example-2',
+                       
'action=wbeditentity&new=property&data={"labels":{"en-gb":{"language":"en-gb","value":"Propertylabel"}},"descriptions":{"en-gb":{"language":"en-gb","value":"Propertydescription"}},"datatype":"string"}'
+                       => 'apihelp-wbeditentity-example-3',
                        // Clearing entities
-                       'api.php?action=wbeditentity&clear=true&id=Q42&data={}'
-                       => 'Clear all data from entity with id Q42',
-                       
'api.php?action=wbeditentity&clear=true&id=Q42&data={"labels":{"en":{"language":"en","value":"en-value"}}}'
-                       => 'Clear all data from entity with id Q42 and set a 
label for en',
+                       'action=wbeditentity&clear=true&id=Q42&data={}'
+                       => 'apihelp-wbeditentity-example-4',
+                       
'action=wbeditentity&clear=true&id=Q42&data={"labels":{"en":{"language":"en","value":"en-value"}}}'
+                       => 'apihelp-wbeditentity-example-5',
                        // Setting stuff
-                       
'api.php?action=wbeditentity&id=Q42&data={"sitelinks":{"nowiki":{"site":"nowiki","title":"København"}}}'
-                       => 'Sets sitelink for nowiki, overwriting it if it 
already exists',
-                       
'api.php?action=wbeditentity&id=Q42&data={"descriptions":{"nb":{"language":"nb","value":"nb-Description-Here"}}}'
-                       => 'Sets description for nb, overwriting it if it 
already exists',
-                       
'api.php?action=wbeditentity&id=Q42&data={"claims":[{"mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ExampleString","type":"string"}},"type":"statement","rank":"normal"}]}'
-                       => 'Creates a new claim on the item for the property 
P56 and a value of "ExampleString"',
-                       
'api.php?action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F","remove":""},{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","remove":""}]}'
-                       => 'Removes the claims from the item with the guids 
Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F and 
Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X',
-                       
'api.php?action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ChangedString","type":"string"}},"type":"statement","rank":"normal"}]}'
-                       => 'Sets the claim with the GUID to the value of the 
claim',
+                       
'action=wbeditentity&id=Q42&data={"sitelinks":{"nowiki":{"site":"nowiki","title":"København"}}}'
+                       => 'apihelp-wbeditentity-example-6',
+                       
'action=wbeditentity&id=Q42&data={"descriptions":{"nb":{"language":"nb","value":"nb-Description-Here"}}}'
+                       => 'apihelp-wbeditentity-example-7',
+                       
'action=wbeditentity&id=Q42&data={"claims":[{"mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ExampleString","type":"string"}},"type":"statement","rank":"normal"}]}'
+                       => 'apihelp-wbeditentity-example-8',
+                       
'action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F","remove":""},{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","remove":""}]}'
+                       => 'apihelp-wbeditentity-example-9',
+                       
'action=wbeditentity&id=Q42&data={"claims":[{"id":"Q42$GH678DSA-01PQ-28XC-HJ90-DDFD9990126X","mainsnak":{"snaktype":"value","property":"P56","datavalue":{"value":"ChangedString","type":"string"}},"type":"statement","rank":"normal"}]}'
+                       => 'apihelp-wbeditentity-example-10',
                );
        }
 
diff --git a/repo/includes/api/FormatSnakValue.php 
b/repo/includes/api/FormatSnakValue.php
index 3ff0c56..9b5f4d5 100644
--- a/repo/includes/api/FormatSnakValue.php
+++ b/repo/includes/api/FormatSnakValue.php
@@ -198,56 +198,25 @@
        }
 
        /**
-        * @see ApiBase::getParamDescription
-        *
-        * @since 0.1
+        * @see ApiBase:getExamplesMessages()
         *
         * @return array
         */
-       public function getParamDescription() {
-               return array(
-                       'generate' => 'The desired output format to generate.',
-                       'datatype' => 'The value\'s data type. This is distinct 
from the value\'s type',
-                       'datavalue' => 'The data to format. This has to be the 
JSON serialization of a DataValue object.',
-                       'options' => 'The options the formatter should use. 
Provided as a JSON object.',
-               );
-       }
-
-       /**
-        * @see ApiBase::getDescription
-        *
-        * @since 0.1
-        *
-        * @return string
-        */
-       public function getDescription() {
-               return array(
-                       'API module for formatting DataValues.'
-               );
-       }
-
-       /**
-        * @see ApiBase::getExamples
-        *
-        * @since 0.1
-        *
-        * @return array
-        */
-       protected function getExamples() {
-               $query = "api.php?action=" . $this->getModuleName() ;
+       protected function getExamplesMessages() {
+               $query = "action=" . $this->getModuleName() ;
                $hello = new StringValue( 'hello' );
                $acme = new StringValue( 'http://acme.org' );
 
                return array(
                        $query . '&' . wfArrayToCgi( array(
                                'datavalue' => json_encode( $hello->toArray() ),
-                       ) ) => 'Format a simple string value.',
+                       ) ) => 'apihelp-wbformatvalue-example-1',
 
                        $query . '&' . wfArrayToCgi( array(
                                'datavalue' => json_encode( $acme->toArray() ),
                                'datatype' => 'url',
                                'generate' => 'text/html',
-                       ) ) => 'Format a string value as a URL in HTML.',
+                       ) ) => 'apihelp-wbformatvalue-example-2',
 
                        //TODO: example for the options parameter, once we have 
something sensible to show there.
                );

-- 
To view, visit https://gerrit.wikimedia.org/r/178079
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc831fd2dcd9c6b2f69d9d3c6608e9bb7ba1be43
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

Reply via email to