function locale_translate_batch_finished

Finished callback of system page locale import batch.

1 call to locale_translate_batch_finished()
locale_translation_batch_fetch_finished in drupal/core/modules/locale/locale.batch.inc
Batch finished callback: Set result message.
1 string reference to 'locale_translate_batch_finished'
locale_translate_batch_build in drupal/core/modules/locale/locale.bulk.inc
Build a locale batch from an array of files.

File

drupal/core/modules/locale/locale.bulk.inc, line 601
Mass import-export and batch import functionality for Gettext .po files.

Code

function locale_translate_batch_finished($success, $results) {
  if ($success) {
    $additions = $updates = $deletes = $skips = $config = 0;
    if (isset($results['failed_files'])) {
      if (Drupal::moduleHandler()
        ->moduleExists('dblog')) {
        $message = format_plural(count($results['failed_files']), 'One translation file could not be imported. <a href="@url">See the log</a> for details.', '@count translation files could not be imported. <a href="@url">See the log</a> for details.', array(
          '@url' => url('admin/reports/dblog'),
        ));
      }
      else {
        $message = format_plural(count($results['failed_files']), 'One translation files could not be imported. See the log for details.', '@count translation files could not be imported. See the log for details.');
      }
      drupal_set_message($message, 'error');
    }
    if (isset($results['files'])) {
      $skipped_files = array();

      // If there are no results and/or no stats (eg. coping with an empty .po
      // file), simply do nothing.
      if ($results && isset($results['stats'])) {
        foreach ($results['stats'] as $filepath => $report) {
          $additions += $report['additions'];
          $updates += $report['updates'];
          $deletes += $report['deletes'];
          $skips += $report['skips'];
          if ($report['skips'] > 0) {
            $skipped_files[] = $filepath;
          }
        }
      }
      drupal_set_message(format_plural(count($results['files']), 'One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', '@count translation files imported. %number translations were added, %update translations were updated and %delete translations were removed.', array(
        '%number' => $additions,
        '%update' => $updates,
        '%delete' => $deletes,
      )));
      watchdog('locale', 'Translations imported: %number added, %update updated, %delete removed.', array(
        '%number' => $additions,
        '%update' => $updates,
        '%delete' => $deletes,
      ));
      if ($skips) {
        if (module_exists('dblog')) {
          $message = format_plural($skips, 'One translation string was skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', array(
            '@url' => url('admin/reports/dblog'),
          ));
        }
        else {
          $message = format_plural($skips, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.');
        }
        drupal_set_message($message, 'warning');
        watchdog('locale', '@count disallowed HTML string(s) in files: @files.', array(
          '@count' => $skips,
          '@files' => implode(',', $skipped_files),
        ), WATCHDOG_WARNING);
      }
    }
  }

  // Add messages for configuration too.
  if (isset($results['stats']['config'])) {
    locale_config_batch_finished($success, $results);
  }
}