Commit eea79f9b authored by Dries's avatar Dries

Issue #1866544 by Sutharsan: Improve Locale batch progress and result messages.

parent 08b21153
......@@ -54,7 +54,7 @@ function locale_translation_batch_status_fetch_remote($source, &$context) {
$context['results']['failed_files'][] = $source->name;
}
$context['results']['sources'][$source->name][$source->langcode] = $source;
$context['message'] = $t('Checked translation file: %name.', array('%name' => $source->name));
$context['message'] = $t('Checked translation for %project.', array('%project' => $source->project));
}
}
......@@ -93,7 +93,7 @@ function locale_translation_batch_status_fetch_local($sources, &$context) {
$context['results']['sources'][$source->name][$source->langcode] = $source;
}
}
$context['message'] = $t('Checked translation files.');
$context['message'] = $t('Checked all translations.');
}
/**
......@@ -113,6 +113,7 @@ function locale_translation_batch_status_fetch_local($sources, &$context) {
* @see locale_translation_batch_status_fetch_local()
*/
function locale_translation_batch_status_compare(&$context) {
$t = get_t();
$history = locale_translation_get_file_history();
$results = array();
......@@ -155,8 +156,8 @@ function locale_translation_batch_status_compare(&$context) {
$results[$project][$langcode] = $source;
}
}
$context['message'] = $t('Updated translation status.');
}
locale_translation_status_save($results);
}
......@@ -248,7 +249,7 @@ function locale_translation_batch_fetch_download($project, $langcode, &$context)
if (isset($source->type) && $source->type == LOCALE_TRANSLATION_REMOTE) {
$t = get_t();
if ($file = locale_translation_download_source($source->files[LOCALE_TRANSLATION_REMOTE])) {
$context['message'] = $t('Imported translation file: %name.', array('%name' => $file->filename));
$context['message'] = $t('Downloaded translation for %project.', array('%project' => $source->project));
$source->files[LOCALE_TRANSLATION_DOWNLOADED] = $file;
}
else {
......@@ -308,7 +309,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
$file = $source_result->files[$import_type];
module_load_include('bulk.inc', 'locale');
$options += array(
'message' => $t('Importing translation file: %name', array('%name' => $file->filename)),
'message' => $t('Importing translation for %project.', array('%project' => $source->project)),
);
// Import the translation file. For large files the batch operations is
// progressive and will be called repeatedly untill finished.
......@@ -318,7 +319,7 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$
if (isset($context['finished']) && $context['finished'] == 1) {
// The import is successfull.
if (isset($context['results']['files'][$file->uri])) {
$context['message'] = $t('Imported translation file: %name.', array('%name' => $file->filename));
$context['message'] = $t('Imported translation for %project.', array('%project' => $source->project));
// Keep the data of imported source. In the following batch
// operation it will be saved in the {locale_file} table.
......
......@@ -404,7 +404,7 @@ function locale_translate_batch_build($files, $options) {
$batch = array(
'operations' => $operations,
'title' => $t('Importing interface translations'),
'init_message' => $t('Starting import'),
'progress_message' => '',
'error_message' => $t('Error importing interface translations'),
'file' => drupal_get_path('module', 'locale') . '/locale.bulk.inc',
);
......@@ -433,7 +433,8 @@ function locale_translate_batch_build($files, $options) {
* are customized translations or come from a community source. Use
* LOCALE_CUSTOMIZED or LOCALE_NOT_CUSTOMIZED. Optional, defaults to
* LOCALE_NOT_CUSTOMIZED.
* - 'message': Alternative message to display during import.
* - 'message': Alternative message to display during import. Note, this must
* be sanitized text.
*
* @param $context
* Contains a list of files imported.
......@@ -470,7 +471,7 @@ function locale_translate_batch_import($file, $options, &$context) {
// http://drupal.org/node/1089472
$context['finished'] = min(0.95, $report['seek'] / filesize($file->uri));
if (isset($options['message'])) {
$context['message'] = t('@message (@percent%).', array('@message' => $options['message'], '@percent' => (int) ($context['finished'] * 100)));
$context['message'] = t('!message (@percent%).', array('!message' => $options['message'], '@percent' => (int) ($context['finished'] * 100)));
}
else {
$context['message'] = t('Importing translation file: %filename (@percent%).', array('%filename' => $file->filename, '@percent' => (int) ($context['finished'] * 100)));
......@@ -532,6 +533,7 @@ function locale_translate_batch_import_save($context) {
locale_translation_update_file_history($file);
}
}
$context['message'] = t('Translations imported.');
}
}
......
......@@ -306,6 +306,7 @@ function locale_translation_batch_status_build($projects = array(), $langcodes =
$batch = array(
'operations' => $operations,
'title' => $t('Checking translations'),
'progress_message' => '',
'finished' => 'locale_translation_batch_status_finished',
'error_message' => $t('Error checking translation updates.'),
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
......
......@@ -38,7 +38,7 @@ function locale_translation_batch_update_build($projects = array(), $langcodes =
$batch = array(
'operations' => $operations,
'title' => $t('Updating translations'),
'init_message' => $t('Downloading and importing translation files.'),
'progress_message' => '',
'error_message' => $t('Error importing translation files'),
'finished' => 'locale_translation_batch_fetch_finished',
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
......@@ -68,7 +68,7 @@ function locale_translation_batch_fetch_build($projects = array(), $langcodes =
$batch = array(
'operations' => _locale_translation_fetch_operations($projects, $langcodes, $options),
'title' => $t('Updating translations.'),
'init_message' => $t('Downloading and importing translation files.'),
'progress_message' => '',
'error_message' => $t('Error importing translation files'),
'finished' => 'locale_translation_batch_fetch_finished',
'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment