function locale_translation_batch_fetch_download

Batch operation: Download a remote translation file.

This operation downloads a remote gettext file and saves it in the temporary directory. The remote file URL is taken from the input data in $context['results']['input']. The result of the operation is stored in $context['results']['sources'] and contains the URL of the temporary file.

Parameters

object $project: Source object of the translatable project.

string $langcode: Language code.

$context: Batch context array.

See also

locale_translation_batch_fetch_sources()

locale_translation_batch_fetch_import()

locale_translation_batch_fetch_update_status()

locale_translation_batch_status_compare()

1 string reference to 'locale_translation_batch_fetch_download'
_locale_translation_fetch_operations in drupal/core/modules/locale/locale.fetch.inc
Helper function to construct the batch operations to fetch translations.

File

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

Code

function locale_translation_batch_fetch_download($project, $langcode, &$context) {
  $sources = $context['results']['input'];
  if (isset($sources[$project . ':' . $langcode])) {
    $source = $sources[$project . ':' . $langcode];
    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('Downloaded translation for %project.', array(
          '%project' => $source->project,
        ));
        $source->files[LOCALE_TRANSLATION_DOWNLOADED] = $file;
      }
      else {
        $context['results']['failed_files'][] = $source->files[LOCALE_TRANSLATION_REMOTE];
      }
      $context['results']['sources'][$project][$langcode] = $source;
    }
  }
}