function locale_translate_batch_finished

Finished callback of system page locale import batch.

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 522
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 = 0;
    $strings = $langcodes = array();
    drupal_set_message(format_plural(count($results['files']), 'One translation file imported.', '@count translation files imported.'));
    $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;
        }
        $strings = array_merge($strings, $report['strings']);
      }

      // Get list of unique string identifiers and language codes updated.
      $strings = array_unique($strings);
      $langcodes = array_unique(array_values($results['languages']));
    }
    drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array(
      '%number' => $additions,
      '%update' => $updates,
      '%delete' => $deletes,
    )));
    watchdog('locale', 'The translation was succesfully imported. %number new strings added, %update updated and %delete removed.', array(
      '%number' => $additions,
      '%update' => $updates,
      '%delete' => $deletes,
    ));
    if ($skips) {
      if (module_exists('dblog')) {
        $skip_message = format_plural($skips, 'A 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 {
        $skip_message = format_plural($skips, 'A 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($skip_message, 'error');
      watchdog('locale', '@count disallowed HTML string(s) in files: @files.', array(
        '@count' => $skips,
        '@files' => implode(',', $skipped_files),
      ), WATCHDOG_WARNING);
    }
    if ($strings) {

      // Clear cache and force refresh of JavaScript translations.
      _locale_refresh_translations($langcodes, $strings);
    }
  }
}