jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/387574 )
Change subject: Added i18n for many of the error messages
......................................................................
Added i18n for many of the error messages
Change-Id: I65ad3f81464190826750bbcac0b76c612032af43
---
M CargoSQLQuery.php
M CargoUtils.php
M formats/CargoGalleryFormat.php
M formats/CargoOutlineFormat.php
M formats/CargoTemplateFormat.php
M formats/CargoTreeFormat.php
M i18n/en.json
M i18n/qqq.json
M parserfunctions/CargoAttach.php
M parserfunctions/CargoDeclare.php
M specials/CargoDeleteTable.php
M specials/CargoExport.php
M specials/CargoSwitchTable.php
M specials/CargoTables.php
14 files changed, 45 insertions(+), 28 deletions(-)
Approvals:
Yaron Koren: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CargoSQLQuery.php b/CargoSQLQuery.php
index f893327..77685f1 100644
--- a/CargoSQLQuery.php
+++ b/CargoSQLQuery.php
@@ -424,7 +424,7 @@
continue;
}
if ( !in_array( $sqlFunction, $allowedFunctions ) ) {
- throw new MWException( "Error: the SQL function
\"$sqlFunction()\" is not allowed." );
+ throw new MWException( wfMessage(
"cargo-query-badsqlfunction", "$sqlFunction()" )->parse() );
}
}
@@ -532,13 +532,13 @@
}
if ( $tableName != null ) {
if ( !array_key_exists( $tableName,
$this->mAliasedTableNames ) ) {
- throw new MWException( "Error:
invalid table alias \"$tableName\"." );
+ throw new MWException(
wfMessage( "cargo-query-badalias", $tableName )->parse() );
}
$actualTableName =
$this->mAliasedTableNames[$tableName];
if ( !array_key_exists(
$actualTableName, $this->mTableSchemas ) ) {
- throw new MWException( "Error:
no database table exists named \"$actualTableName\"." );
+ throw new MWException(
wfMessage( "cargo-query-unknowndbtable", $actualTableName )->parse() );
} elseif ( !array_key_exists(
$fieldName, $this->mTableSchemas[$actualTableName]->mFieldDescriptions ) ) {
- throw new MWException( "Error:
no field named \"$fieldName\" found for the database table
\"$actualTableName\"." );
+ throw new MWException(
wfMessage( "cargo-query-unknownfieldfortable", $fieldName, $actualTableName
)->parse() );
} else {
$description =
$this->mTableSchemas[$actualTableName]->mFieldDescriptions[$fieldName];
}
@@ -569,7 +569,7 @@
// If we couldn't find a table name,
// throw an error.
if ( $tableName == '' ) {
- throw new MWException( "Error:
no field named \"$fieldName\" found for any of the specified database tables."
);
+ throw new MWException(
wfMessage( "cargo-query-unknownfield", $fieldName )->parse() );
}
}
}
diff --git a/CargoUtils.php b/CargoUtils.php
index 641a4a2..4fe8c9c 100644
--- a/CargoUtils.php
+++ b/CargoUtils.php
@@ -169,7 +169,7 @@
if ( count( $tableSchemas ) < count( $mainTableNames ) ) {
foreach ( $mainTableNames as $tableName ) {
if ( !array_key_exists( $tableName,
$tableSchemas ) ) {
- throw new MWException( "Error: table
\"$tableName\" not found." );
+ throw new MWException( wfMessage(
"cargo-unknowntable", $tableName )->parse() );
}
}
}
diff --git a/formats/CargoGalleryFormat.php b/formats/CargoGalleryFormat.php
index bde95e9..078680f 100644
--- a/formats/CargoGalleryFormat.php
+++ b/formats/CargoGalleryFormat.php
@@ -90,7 +90,7 @@
$captionField[0] = '_';
}
if ( count( $valuesTable ) > 0 && !array_key_exists(
$captionField, $valuesTable[0] ) ) {
- throw new MWException( "Error: the caption
field \"$captionField\" must be among this query's fields." );
+ throw new MWException( wfMessage(
"cargo-query-specifiedfieldmissing", $captionField, "caption field" )->parse()
);
}
$this->undisplayedFields[] = $captionField;
} else {
@@ -102,7 +102,7 @@
$altField[0] = '_';
}
if ( count( $valuesTable ) > 0 && !array_key_exists(
$altField, $valuesTable[0] ) ) {
- throw new MWException( "Error: the alt field
\"$altField\" must be among this query's fields." );
+ throw new MWException( wfMessage(
"cargo-query-specifiedfieldmissing", $altField, "alt field" )->parse() );
}
$this->undisplayedFields[] = $altField;
} else {
@@ -114,7 +114,7 @@
$linkField[0] = '_';
}
if ( count( $valuesTable ) > 0 && !array_key_exists(
$linkField, $valuesTable[0] ) ) {
- throw new MWException( "Error: the link field
\"$linkField\" must be among this query's fields." );
+ throw new MWException( wfMessage(
"cargo-query-specifiedfieldmissing", $linkField, "link field" )->parse() );
}
$this->undisplayedFields[] = $linkField;
} else {
diff --git a/formats/CargoOutlineFormat.php b/formats/CargoOutlineFormat.php
index eab5234..26e8ece 100644
--- a/formats/CargoOutlineFormat.php
+++ b/formats/CargoOutlineFormat.php
@@ -42,8 +42,7 @@
function getOutlineFieldValues( $fieldName ) {
if ( !array_key_exists( $fieldName, $this->mOutlineFields ) ) {
- throw new MWException( "Error: the outline field
'$fieldName' must be among this "
- . "query's fields." );
+ throw new MWException( wfMessage(
"cargo-query-specifiedfieldmissing", $fieldName, "outline fields" )->parse() );
}
return $this->mOutlineFields[$fieldName]['unformatted'];
}
@@ -153,7 +152,7 @@
function display( $valuesTable, $formattedValuesTable,
$fieldDescriptions, $displayParams ) {
if ( !array_key_exists( 'outline fields', $displayParams ) ) {
- throw new MWException( "Error: 'outline fields'
parameter must be set for 'outline' format." );
+ throw new MWException( wfMessage(
"cargo-query-missingparam", "outline fields", "outline" )->parse() );
}
$outlineFields = explode( ',', str_replace( '_', ' ',
$displayParams['outline fields'] ) );
$this->mOutlineFields = array_map( 'trim', $outlineFields );
diff --git a/formats/CargoTemplateFormat.php b/formats/CargoTemplateFormat.php
index 05af76c..3363f4a 100644
--- a/formats/CargoTemplateFormat.php
+++ b/formats/CargoTemplateFormat.php
@@ -37,7 +37,7 @@
*/
function display( $valuesTable, $formattedValuesTable,
$fieldDescriptions, $displayParams ) {
if ( !array_key_exists( 'template', $displayParams ) ) {
- throw new MWException( "Error: 'template' parameter
must be set." );
+ throw new MWException( wfMessage(
"cargo-query-missingparam", "template", "template" )->parse() );
}
$templateName = $displayParams['template'];
diff --git a/formats/CargoTreeFormat.php b/formats/CargoTreeFormat.php
index 91c6e8a..990c90f 100644
--- a/formats/CargoTreeFormat.php
+++ b/formats/CargoTreeFormat.php
@@ -101,15 +101,14 @@
*/
function display( $valuesTable, $formattedValuesTable,
$fieldDescriptions, $displayParams ) {
if ( !array_key_exists( 'parent field', $displayParams ) ) {
- throw new MWException( "Error: 'parent field' parameter
must be set for 'tree' format." );
+ throw new MWException( wfMessage(
"cargo-query-missingparam", "parent field", "tree" )->parse() );
}
$this->mParentField = str_replace( '_', ' ', trim(
$displayParams['parent field'] ) );
$this->mFieldDescriptions = $fieldDescriptions;
// Early error-checking.
if ( !array_key_exists( $this->mParentField, $fieldDescriptions
) ) {
- throw new MWException( "Error: 'parent field' value,
\"" . $this->mParentField .
- "\", must be one of the queried fields." );
+ throw new MWException( wfMessage(
"cargo-query-specifiedfieldmissing", $this->mParentField, "parent field"
)->parse() );
}
if ( array_key_exists( 'isList',
$fieldDescriptions[$this->mParentField] ) ) {
throw new MWException( "Error: 'parent field' is
declared to hold a list of values; "
diff --git a/i18n/en.json b/i18n/en.json
index 391e841..303c5ad 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -7,6 +7,8 @@
"cargo-definestable": "This template defines the table \"$1\".",
"cargo-tablenotcreated": "This table has not been created yet.",
"cargo-addsrows": "This template adds rows to the table \"$1\".",
+ "cargo-notable": "Error: Table name must be specified.",
+ "cargo-unknowntable": "Error: Table $1 not found.",
"recreatedata": "Recreate data",
"action-recreatecargodata": "recreate Cargo data",
"action-deletecargodata": "delete Cargo data",
@@ -54,6 +56,14 @@
"cargo-viewdata-orderby": "Order by:",
"cargo-viewdata-limit": "Limit:",
"cargo-viewdata-format": "Format:",
+ "cargo-query-missingformat": "Error: Format must be set.",
+ "cargo-query-badsqlfunction": "Error: The SQL function \"$1\" is not
allowed.",
+ "cargo-query-badalias": "Error: Invalid table alias \"$1\".",
+ "cargo-query-unknowndbtable": "Error: No database table exists named
\"$1\".",
+ "cargo-query-unknownfieldfortable": "Error: No field named \"$1\" found
for the database table \"$2\".",
+ "cargo-query-unknownfield": "Error: No field named \"$1\" found for any
of the specified database tables.",
+ "cargo-query-missingparam": "Error: The \"$1\" parameter must be set
for the \"$2\" format.",
+ "cargo-query-specifiedfieldmissing": "Error: the field \"$1\",
specified as the \"$2\", must be among this query's fields.",
"cargotables": "Cargo tables",
"cargo-cargotables-beingpopulated": "<strong>Note:</strong> One or more
of these tables are currently being populated, via the job queue.",
"cargo-cargotables-tablelist": "The following {{PLURAL:$1|table
is|tables are}} defined:",
@@ -68,6 +78,7 @@
"cargo-cargotables-totalrows": "This table has '''$1'''
{{PLURAL:$1|row|rows}} altogether.",
"cargo-cargotables-totalrowsshort": "$1 {{PLURAL:$1|row|rows}}",
"cargo-cargotables-switch": "Switch to using this table.",
+ "cargo-cargotables-nonexistenttable": "This table is registered, but
does not exist!",
"deletecargotable": "Delete Cargo table",
"switchcargotable": "Switch in replacement Cargo table",
"pagevalues": "Page values",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 604c148..0216b2d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -13,6 +13,8 @@
"cargo-definestable": "A description of a template, that is displayed
on that template's page.",
"cargo-tablenotcreated": "A notice to the user, displayed on a template
page.",
"cargo-addsrows": "A description of a template, that is displayed on
that template's page.",
+ "cargo-notable": "An error message.",
+ "cargo-unknowntable": "An error message. Parameters:\n* $1 - a database
table name",
"recreatedata": "{{doc-special|RecreateData}}",
"action-recreatecargodata":
"{{doc-action|recreatecargodata}}\n{{doc-cargo}}",
"action-deletecargodata":
"{{doc-action|deletecargodata}}\n{{doc-cargo}}",
@@ -60,6 +62,14 @@
"cargo-viewdata-orderby": "Label in a form to set the sort order for
query results.",
"cargo-viewdata-limit": "Label in a form to set the limit on the number
of results of a query.\n{{Identical|Limit}}",
"cargo-viewdata-format": "Label in a form to set the display format for
query results.\n{{Identical|Format}}",
+ "cargo-query-missingformat": "An error message.",
+ "cargo-query-badsqlfunction": "An error message. Parameters:\n* $1 -
form name (with link)",
+ "cargo-query-badalias": "An error message. Parameters:\n* $1 - an SQL
table alias",
+ "cargo-query-unknowndbtable": "An error message. Parameters:\n* $1 - a
database table name",
+ "cargo-query-unknownfieldfortable": "An error message. Parameters:\n*
$1 - a database field name\n* $2 - a database table name",
+ "cargo-query-unknownfield": "An error message. Parameters:\n* $1 - a
database field name",
+ "cargo-query-missingparam": "An error message. Parameters:\n* $1 - a
#cargo_query parameter name\n* $2 - a display format name",
+ "cargo-query-specifiedfieldmissing": "An error message. Parameters:\n*
$1 - a database field name\n* $2 - a #cargo_query parameter name",
"cargotables": "{{doc-special|CargoTables}}\n{{doc-cargo}}",
"cargo-cargotables-beingpopulated": "An informational message to the
user.",
"cargo-cargotables-tablelist": "Used as a page header.",
@@ -74,6 +84,7 @@
"cargo-cargotables-totalrows": "Parameters:\n* $1 - number of rows in a
database table.",
"cargo-cargotables-totalrowsshort": "Parameters:\n* $1 - number of rows
in a database table.",
"cargo-cargotables-switch": "The text of a link to a subpage of
[[Special:SwitchCargoTable]].",
+ "cargo-cargotables-nonexistenttable": "An error message.",
"deletecargotable": "{{doc-special|DeleteCargoTable}}\n{{doc-cargo}}",
"switchcargotable": "{{doc-special|SwitchCargoTable}}\n{{doc-cargo}}",
"pagevalues": "{{doc-special|PageValues}}",
diff --git a/parserfunctions/CargoAttach.php b/parserfunctions/CargoAttach.php
index ebf862e..f302852 100644
--- a/parserfunctions/CargoAttach.php
+++ b/parserfunctions/CargoAttach.php
@@ -38,7 +38,7 @@
// Validate table name.
if ( $tableName == '' ) {
- return CargoUtils::formatError( "Error: Table name must
be specified." );
+ return CargoUtils::formatError( wfMessage(
"cargo-notable" )->parse() );
}
$dbw = wfGetDB( DB_MASTER );
diff --git a/parserfunctions/CargoDeclare.php b/parserfunctions/CargoDeclare.php
index 381d14b..b5d9cd6 100644
--- a/parserfunctions/CargoDeclare.php
+++ b/parserfunctions/CargoDeclare.php
@@ -85,7 +85,7 @@
// Validate table name.
if ( $tableName == '' ) {
- return CargoUtils::formatError( "Error: Table name must
be specified." );
+ return CargoUtils::formatError( wfMessage(
"cargo-notable" )->parse() );
} elseif ( strpos( $tableName, ' ' ) !== false ) {
return CargoUtils::formatError( "Error: Table name
\"$tableName\" contains spaces. "
. "Spaces are not allowed; consider
using underscores(\"_\") instead." );
diff --git a/specials/CargoDeleteTable.php b/specials/CargoDeleteTable.php
index 7278097..4c8e016 100644
--- a/specials/CargoDeleteTable.php
+++ b/specials/CargoDeleteTable.php
@@ -57,8 +57,7 @@
$this->setHeaders();
if ( $subpage == '' ) {
- /** @todo i18n for these error messages */
- $out->addHTML( CargoUtils::formatError( "Error: table
name must be set." ) );
+ $out->addHTML( CargoUtils::formatError( wfMessage(
"cargo-notable" )->parse() ) );
return true;
}
@@ -75,7 +74,7 @@
$res = $dbr->select( 'cargo_tables', array( 'main_table',
'field_tables', 'field_helper_tables' ),
array( 'main_table' => $tableName ) );
if ( $res->numRows() == 0 ) {
- $out->addHTML( CargoUtils::formatError( "Error: no
table found named \"$tableName\"." ) );
+ $out->addHTML( CargoUtils::formatError( wfMessage(
"cargo-unknowntable", $tableName )->parse() ) );
return true;
}
diff --git a/specials/CargoExport.php b/specials/CargoExport.php
index faf8976..3501d91 100644
--- a/specials/CargoExport.php
+++ b/specials/CargoExport.php
@@ -75,7 +75,7 @@
} elseif ( $format == 'json' ) {
$this->displayJSONData( $sqlQueries );
} else {
- print "Error: format must be set.";
+ print wfMessage( "cargo-query-missingformat" )->parse();
}
}
diff --git a/specials/CargoSwitchTable.php b/specials/CargoSwitchTable.php
index 3e4e9da..03ab1fe 100644
--- a/specials/CargoSwitchTable.php
+++ b/specials/CargoSwitchTable.php
@@ -77,8 +77,7 @@
$this->setHeaders();
if ( $tableName == '' ) {
- /** @todo i18n for these error messages */
- $out->addHTML( CargoUtils::formatError( "Error: table
name must be set." ) );
+ $out->addHTML( CargoUtils::formatError( wfMessage(
"cargo-notable" )->parse() ) );
return true;
}
@@ -87,13 +86,13 @@
$res = $dbr->select( 'cargo_tables', array( 'main_table',
'field_tables', 'field_helper_tables' ),
array( 'main_table' => $tableName ) );
if ( $res->numRows() == 0 ) {
- $out->addHTML( CargoUtils::formatError( "Error: no
table found named \"$tableName\"." ) );
+ $out->addHTML( CargoUtils::formatError( wfMessage(
"cargo-unknowntable", $tableName )->parse() ) );
return true;
}
$res = $dbr->select( 'cargo_tables', array( 'main_table',
'field_tables', 'field_helper_tables' ),
array( 'main_table' => $tableName . '__NEXT' ) );
if ( $res->numRows() == 0 ) {
- $out->addHTML( CargoUtils::formatError( "Error: no
table found named \"$tableName" . "__NEXT\"." ) );
+ $out->addHTML( CargoUtils::formatError( wfMessage(
"cargo-unknowntable", $tableName . "__NEXT" )->parse() ) );
return true;
}
diff --git a/specials/CargoTables.php b/specials/CargoTables.php
index 76ac859..0cc9cca 100644
--- a/specials/CargoTables.php
+++ b/specials/CargoTables.php
@@ -264,8 +264,7 @@
foreach ( $tableNames as $tableName ) {
if ( !$cdb->tableExists( $tableName ) ) {
$tableText = "$tableName - ";
- // @TODO - this should probably be an i18n
message.
- $tableText .= "<span class=\"error\">Table is
registered, but does not exist!</span>";
+ $tableText .= '<span class="error">' .
wfMessage( "cargo-cargotables-nonexistenttable" )->parse() . '</span>';
$text .= Html::rawElement( 'li', null,
$tableText );
continue;
}
--
To view, visit https://gerrit.wikimedia.org/r/387574
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I65ad3f81464190826750bbcac0b76c612032af43
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits