Problem/Motivation

During tests of #1804702: Display interface translation status the progress messages of Locale's check, download and import batch operations proved to be confusing. The default "Completed @count of @total" message confused because the '@total' does not match the number of projects checked/imported.

Proposed resolution

Remove clutter. Show what is needed for an indication of the task in progress. Provide feedback after batch completion that is relevant and (if required) actionable.

Remaining tasks

To be determined

User interface changes

Changes to user interface text.

API changes

None

Comments

Sutharsan’s picture

Title:Improve Locale batch progress messages» Improve Locale batch progress and result messages
StatusFileSize
new28.27 KB
new22.96 KB
new21.63 KB
new14.98 KB
new11.27 KB
new5.22 KB
FAILED: [[SimpleTest]]: [MySQL] 49,328 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

This patch improves the batch progress messages. Screenshots below show various states of an import process after enabling a language. You can see the process in action on this video.

locale-batch-messages-1866544-1.1.pnglocale-batch-messages-1866544-1.2.pnglocale-batch-messages-1866544-1.3.pnglocale-batch-messages-1866544-1.4.pnglocale-batch-messages-1866544-1.5.png

Sutharsan’s picture

Issue tags:+language-ui

Adding more tags

Gábor Hojtsy’s picture

Status:Needs work» Needs review
Gábor Hojtsy’s picture

Status:Needs review» Needs work

First of all I like the changes. The screenshot illustrates the improved UI very well. Reviewing the patch I also like that concrete file names are now replaced by project names. We want to automate file downloads and imports for users, so the files are just a means of getting the translations and users will have no exposure to them. The download and import is all automated. So it is internal detail at this point and we don't need to put that burden on the user to understand. There are also different things intertwined in the batches, and the general progress is clearly visible while more user friendly messages help the user to understand what is going on currently. My only concern is the application of the project name display:

+++ b/core/modules/locale/locale.batch.incundefined
@@ -54,7 +54,7 @@ function locale_translation_batch_status_fetch_remote($source, &$context) {
-    $context['message'] = $t('Checked translation file: %name.', array('%name' => $source->name));
+    $context['message'] = $t('Checked translation for %project.', array('%project' => $source->project));

@@ -248,7 +249,7 @@ function locale_translation_batch_fetch_download($project, $langcode, &$context)
-        $context['message'] = $t('Imported translation file: %name.', array('%name' => $file->filename));
+        $context['message'] = $t('Downloaded translation for %project.', array('%project' => $source->project));

@@ -308,7 +309,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
-          'message' => $t('Importing translation file: %name', array('%name' => $file->filename)),
+          'message' => $t('Importing translation for @project.', array('@project' => $source->project)),

@@ -318,7 +319,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
-            $context['message'] = $t('Imported translation file: %name.', array('%name' => $file->filename));
+            $context['message'] = $t('Imported translation for %project.', array('%project' => $source->project));

@project or %project does not seem to be consistently applied.

Looks good otherwise!

Gábor Hojtsy’s picture

Issue tags:+sprint
Sutharsan’s picture

@@ -308,7 +309,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
- 'message' => $t('Importing translation file: %name', array('%name' => $file->filename)),
+ 'message' => $t('Importing translation for @project.', array('@project' => $source->project)),

Using @project here is on purpose, but perhaps someone else has a better solution.

The above 'message' text is used as the variable in the code below for the import progress. In the code below the <em> text is escaped.
          $context['message'] = t('@message (@percent%).', array('@message' => $options['message'], '@percent' => (int) ($context['finished'] * 100)));
Either we use t('!message (@percent%).', ... and not sanitize 'message' but it is potentially bad for security, or not translate the text $message .' (' . $percent).' . ')' witch is bad for translators and rtl languages, or we are inconsistent with @project versus %project. I don't see a better solution.

Gábor Hojtsy’s picture

I don't think using !message is bad, the output of t() is assumed to be "secure" as long as the input was (appropriate placeholders are used for replacement data).

Sutharsan’s picture

Status:Needs work» Needs review
StatusFileSize
new3.02 KB
new7.3 KB
PASSED: [[SimpleTest]]: [MySQL] 49,355 pass(es).
[ View ]

Changed @project into %project.
Changed @message to !message and added a note that the string must be sanitized.
Made the same UI changes to the file import batch. i.e. removed the "Completed @count of @total" text.

Gábor Hojtsy’s picture

Status:Needs review» Reviewed & tested by the community

Looks good to me.

Dries’s picture

Status:Reviewed & tested by the community» Fixed

Committed to 8.x.

Gábor Hojtsy’s picture

Issue tags:-sprint

Woot, thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.