function locale_translation_download_source

Same name and namespace in other branches
  1. 10 core/modules/locale/locale.batch.inc \locale_translation_download_source()
  2. 11.x core/modules/locale/locale.batch.inc \locale_translation_download_source()
  3. 9 core/modules/locale/locale.batch.inc \locale_translation_download_source()
  4. 8.9.x core/modules/locale/locale.batch.inc \locale_translation_download_source()

Downloads a translation file from a remote server.

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.

string $directory: Directory where the downloaded file will be saved. Defaults to the temporary file path.

Return value

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

Deprecated

in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::service(LocaleFileManager::class) ->downloadTranslationSource($source_file, $directory) instead.

See also

https://www.drupal.org/node/3577675

File

core/modules/locale/locale.batch.inc, line 349

Code

function locale_translation_download_source($source_file, $directory = 'temporary://') {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(LocaleFileManager::class)->downloadTranslationSource($source_file, $directory) instead. See https://www.drupal.org/node/3577675', E_USER_DEPRECATED);
  $hash = hash_file(LocaleSource::LOCAL_FILE_HASH_ALGO, $source_file->uri);
  $locale_file = new LocaleFile($source_file->filename, $source_file->uri, $hash);
  return \Drupal::service(LocaleFileManager::class)->downloadTranslationSource($locale_file, $directory);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.