function locale_translation_batch_status_compare

Batch operation callback: Compare states and store the result.

In the preceding batch processes data of remote and local translation sources is collected. Here we compare the collected results and update the source object with the data of the most recent translation file. The end result is stored in the 'locale_translation_status' state variable. Other processes can collect this data after the batch process is completed.

Parameters

array $context: The batch context array. The 'results' element contains a structured array of project data with languages, local and remote source data.

See also

locale_translation_batch_status_fetch_remote()

locale_translation_batch_status_fetch_local()

1 string reference to 'locale_translation_batch_status_compare'
locale_translation_batch_status_build in drupal/core/modules/locale/locale.batch.inc
Build a batch to get the status of remote and local translation files.

File

drupal/core/modules/locale/locale.batch.inc, line 129
Batch process to check the availability of remote or local po files.

Code

function locale_translation_batch_status_compare(&$context) {
  module_load_include('compare.inc', 'locale');
  $results = array();
  foreach ($context['results'] as $project => $langcodes) {
    foreach ($langcodes as $langcode => $source) {
      $local = isset($source->files['local']) ? $source->files['local'] : NULL;
      $remote = isset($source->files['remote']) ? $source->files['remote'] : NULL;

      // The available translation files are compare and data of the most recent
      // file is used to update the source object.
      $file = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local;
      if (isset($file->timestamp)) {
        $source->type = $file->type;
        $source->timestamp = $file->timestamp;
        $results[$project][$langcode] = $source;
      }
    }
  }
  state()
    ->set('locale_translation_status', $results);
  state()
    ->set('locale_translation_status_last_update', REQUEST_TIME);
}