function l10n_update_batch_fetch_download in Localization update 7.2
Batch operation: Download a remote translation file.
Downloads a remote gettext file into the translations directory. When successfully the translation status is updated.
Parameters
string $project: Name of the translatable project.
string $langcode: Language code.
array $context: The batch context.
See also
l10n_update_batch_fetch_import()
1 string reference to 'l10n_update_batch_fetch_download'
- _l10n_update_fetch_operations in ./
l10n_update.fetch.inc - Helper function to construct the batch operations to fetch translations.
File
- ./
l10n_update.batch.inc, line 135 - Batch process to check the availability of remote or local po files.
Code
function l10n_update_batch_fetch_download($project, $langcode, &$context) {
$sources = l10n_update_get_status(array(
$project,
), array(
$langcode,
));
if (isset($sources[$project][$langcode])) {
$source = $sources[$project][$langcode];
if (isset($source->type) && $source->type == L10N_UPDATE_REMOTE) {
if ($file = l10n_update_download_source($source->files[L10N_UPDATE_REMOTE], 'translations://')) {
$context['message'] = t('Downloaded translation for %project.', array(
'%project' => $source->project,
));
l10n_update_status_save($source->name, $source->langcode, L10N_UPDATE_LOCAL, $file);
}
else {
$context['results']['failed_files'][] = $source->files[L10N_UPDATE_REMOTE];
}
}
}
}