function locale_translation_download_source

Downloads source file from a remote server.

The downloaded file is stored in the temporary files directory.

Parameters

object $source_file: Source file object with at least:

  • "uri": uri to download the file from.
  • "project": Project name.
  • "langcode": Translation language.
  • "version": Project version.
  • "filename": File name.

Return value

object File object if download was successful. FALSE on failure.

1 call to locale_translation_download_source()
locale_translation_batch_fetch_download in drupal/core/modules/locale/locale.batch.inc
Batch operation: Download a remote translation file.

File

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

Code

function locale_translation_download_source($source_file) {
  if ($uri = system_retrieve_file($source_file->uri, 'temporary://')) {
    $file = new stdClass();
    $file->project = $source_file->project;
    $file->langcode = $source_file->langcode;
    $file->version = $source_file->version;
    $file->type = LOCALE_TRANSLATION_DOWNLOADED;
    $file->uri = $uri;
    $file->filename = $source_file->filename;
    return $file;
  }
  watchdog('locale', 'Unable to download translation file @uri.', array(
    '@uri' => $source->files[LOCALE_TRANSLATION_REMOTE]->uri,
  ), WATCHDOG_ERROR);
  return FALSE;
}