From 98473f59fe34507f84fdcc12d315ce09ddad5d49 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 3 Nov 2016 15:16:57 -0400 Subject: [PATCH] Update for API error i18n See Iae0e2ce3. Since TemplateData master requires core master, this just depends on the master patch instead of trying to maintain BC. Depends-On: Iae0e2ce3bd42dd4776a9779664086119ac188412 Change-Id: Iebe8557affd5ecf206814e7fdef5d8656417dadb --- api/ApiTemplateData.php | 13 +++++-------- i18n/en.json | 2 ++ i18n/qqq.json | 2 ++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api/ApiTemplateData.php b/api/ApiTemplateData.php index 82eed136..d66ae1f2 100644 --- a/api/ApiTemplateData.php +++ b/api/ApiTemplateData.php @@ -19,11 +19,9 @@ class ApiTemplateData extends ApiBase { */ public function getCustomPrinter() { if ( $this->getMain()->getVal( 'format' ) === null ) { - $this->setWarning( - "The default output format will change to jsonfm in the future." . - " Please specify format=json explicitly." + $this->addDeprecation( + 'apiwarn-templatedata-deprecation-format', 'action=templatedata&!format' ); - $this->logFeatureUsage( 'action=templatedata&!format' ); return $this->getMain()->createPrinterByName( 'json' ); } return null; @@ -46,7 +44,7 @@ class ApiTemplateData extends ApiBase { if ( is_null( $params['lang'] ) ) { $langCode = false; } elseif ( !Language::isValidCode( $params['lang'] ) ) { - $this->dieUsage( 'Invalid language code for parameter lang', 'invalidlang' ); + $this->dieWithError( [ 'apierror-invalidlang', 'lang' ] ); } else { $langCode = $params['lang']; } @@ -78,9 +76,8 @@ class ApiTemplateData extends ApiBase { $status = $tdb->getStatus(); if ( !$status->isOK() ) { - $this->dieUsage( - 'Page #' . intval( $row->pp_page ) . ' templatedata contains invalid data: ' - . $status->getMessage(), 'templatedata-corrupt' + $this->dieWithError( + [ 'apierror-templatedata-corrupt', intval( $row->pp_page ), $status->getMessage() ] ); } diff --git a/i18n/en.json b/i18n/en.json index 8f59418f..46bac4a9 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -10,6 +10,8 @@ "apihelp-templatedata-description": "Fetch data stored by the TemplateData extension.", "apihelp-templatedata-example-1": "Return data for [[Template:Stub]] and [[Template:Example]]", "apihelp-templatedata-param-lang": "Return localized values in this language. By default all available translations are returned.", + "apierror-templatedata-corrupt": "Page #$1 templatedata contains invalid data: $2", + "apiwarn-templatedata-deprecation-format": "The default output format will change to jsonfm in the future. Please specify format=json explicitly.", "templatedata-desc": "Implement data storage for template parameters (using JSON)", "templatedata-doc-desc-empty": "No description.", "templatedata-doc-format-inline": "This template prefers inline formatting of parameters.", diff --git a/i18n/qqq.json b/i18n/qqq.json index 23ddc0bf..3aca464c 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -20,6 +20,8 @@ "apihelp-templatedata-description": "{{doc-apihelp-description|templatedata}}", "apihelp-templatedata-example-1": "{{doc-apihelp-example|templatedata}}", "apihelp-templatedata-param-lang": "{{doc-apihelp-param|templatedata|lang}}", + "apierror-templatedata-corrupt": "{{doc-apierror}}\n\nParameters:\n* $1 - Page ID number\n* $2 - Localized message with further information.", + "apiwarn-templatedata-deprecation-format": "{{doc-apierror}}", "templatedata-desc": "{{desc|name=Template Data|url=https://www.mediawiki.org/wiki/Extension:TemplateData}}", "templatedata-doc-desc-empty": "Displayed when a template has no description (should be a valid sentence).\n{{Identical|No description}}", "templatedata-doc-format-inline": "Use inline formatting of the template parameters in wikitext.",