jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/334907 )
Change subject: Actually import the new translations in
Special:ImportTranslations
......................................................................
Actually import the new translations in Special:ImportTranslations
Also document the function a bit more.
Bug: T151585
Change-Id: I176ea790506edc610cf74ea88842358820569b7f
---
M utils/MessageWebImporter.php
1 file changed, 35 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Nikerabbit: Checked; Looks good to me, approved
diff --git a/utils/MessageWebImporter.php b/utils/MessageWebImporter.php
index 455a961..cd34404 100644
--- a/utils/MessageWebImporter.php
+++ b/utils/MessageWebImporter.php
@@ -191,15 +191,18 @@
$this->out->addHTML( $this->doHeader() );
- // Determine changes
+ // Initialise variable to keep track whether all changes were
imported
+ // or not. If we're allowed to process, initially assume they
were.
$alldone = $process;
+
+ // Determine changes for each message.
$changed = array();
foreach ( $messages as $key => $value ) {
$fuzzy = $old = null;
if ( isset( $collection[$key] ) ) {
- // This returns null for if no existing
translation
+ // This returns null if no existing translation
is found
$old = $collection[$key]->translation();
}
@@ -209,6 +212,18 @@
}
if ( $old === null ) {
+ // We found a new translation for this message
of the
+ // current group: import it.
+ $action = 'import';
+ $message = self::doAction(
+ $action,
+ $group,
+ $key,
+ $code,
+ $value
+ );
+
+ // Show the user that we imported the new
translation
$para = '<code class="mw-tmi-new">' .
htmlspecialchars( $key ) . '</code>';
$name = $context->msg(
'translate-manage-import-new' )->rawParams( $para )
->escaped();
@@ -217,26 +232,33 @@
} else {
$oldContent = ContentHandler::makeContent(
$old, $diff->getTitle() );
$newContent = ContentHandler::makeContent(
$value, $diff->getTitle() );
-
$diff->setContent( $oldContent, $newContent );
-
$text = $diff->getDiff( '', '' );
+
+ // This is a changed translation. Note it for
the next steps.
$type = 'changed';
+ // Get the user instructions for the current
message,
+ // submitted together with the form
$action = $context->getRequest()
->getVal( self::escapeNameForPHP(
"action-$type-$key" ) );
if ( $process ) {
if ( !count( $changed ) ) {
+ // Initialise the HTML list
showing the changes performed
$changed[] = '<ul>';
}
if ( $action === null ) {
+ // We have been told to process
the messages, but not
+ // what to do with this one.
Tell the user.
$message = $context->msg(
'translate-manage-inconsistent',
wfEscapeWikiText(
"action-$type-$key" )
)->parse();
$changed[] =
"<li>$message</li></ul>";
+
+ // Also stop any further
processing for the other messages.
$process = false;
} else {
// Check processing time
@@ -244,6 +266,8 @@
$this->time =
wfTimestamp();
}
+ // We have all the necessary
information on this changed
+ // translation: actually
process the message
$message = self::doAction(
$action,
$group,
@@ -252,23 +276,30 @@
$value
);
+ // Show what we just did,
adding to the list of changes
$key = array_shift( $message );
$params = $message;
$message = $context->msg( $key,
$params )->parse();
$changed[] =
"<li>$message</li>";
+ // Stop processing further
messages if too much time
+ // has been spent.
if ( $this->checkProcessTime()
) {
$process = false;
$message =
$context->msg( 'translate-manage-toolong' )
->numParams(
$this->processingTime )->parse();
$changed[] =
"<li>$message</li></ul>";
}
+
continue;
}
}
+ // We are not processing messages, or no
longer, or this was an
+ // unactionable translation. We will eventually
return false
$alldone = false;
+ // Prepare to ask the user what to do with this
message
$actions = $this->getActions();
$defaction = $this->getDefaultAction( $fuzzy,
$action );
--
To view, visit https://gerrit.wikimedia.org/r/334907
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I176ea790506edc610cf74ea88842358820569b7f
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nemo bis <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Seb35 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits