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.
object $project: Source object of the translatable project.
string $langcode: Language code.
$context: Batch context array.
locale_translation_batch_fetch_sources()
locale_translation_batch_fetch_import()
locale_translation_batch_fetch_update_status()
locale_translation_batch_status_compare()
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;
}
}
}