locale_translation_batch_fetch_download($project, $langcode, &$context)
Implements callback_batch_operation().
Downloads a remote gettext file into the translations directory. When successfully the translation status is updated.
object $project: Source object of the translatable project.
string $langcode: Language code.
array $context: The batch context.
locale_translation_batch_fetch_import()
function locale_translation_batch_fetch_download($project, $langcode, &$context) { $sources = locale_translation_get_status(array($project), array($langcode)); if (isset($sources[$project][$langcode])) { $source = $sources[$project][$langcode]; if (isset($source->type) && $source->type == LOCALE_TRANSLATION_REMOTE) { if ($file = locale_translation_download_source($source->files[LOCALE_TRANSLATION_REMOTE], 'translations://')) { $context['message'] = t('Downloaded translation for %project.', array('%project' => $source->project)); locale_translation_status_save($source->name, $source->langcode, LOCALE_TRANSLATION_LOCAL, $file); } else { $context['results']['failed_files'][] = $source->files[LOCALE_TRANSLATION_REMOTE]; } } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!locale!locale.batch.inc/function/locale_translation_batch_fetch_download/8.1.x