function locale_translation_batch_fetch_download
Same name in other branches
- 9 core/modules/locale/locale.batch.inc \locale_translation_batch_fetch_download()
- 8.9.x core/modules/locale/locale.batch.inc \locale_translation_batch_fetch_download()
- 11.x core/modules/locale/locale.batch.inc \locale_translation_batch_fetch_download()
Implements callback_batch_operation().
Downloads a remote gettext file into the translations directory. When successfully the translation status is updated.
Parameters
object $project: Source object of the translatable project.
string $langcode: Language code.
array $context: The batch context.
See also
locale_translation_batch_fetch_import()
1 call to locale_translation_batch_fetch_download()
- LocaleTranslationChangeProjectVersionTest::testUpdateImportSourceRemote in core/
modules/ locale/ tests/ src/ Functional/ LocaleTranslationChangeProjectVersionTest.php - Tests update translations when project version changes.
2 string references to 'locale_translation_batch_fetch_download'
- install_import_translations in core/
includes/ install.core.inc - Imports languages via a batch process during installation.
- _locale_translation_fetch_operations in core/
modules/ locale/ locale.fetch.inc - Helper function to construct the batch operations to fetch translations.
File
-
core/
modules/ locale/ locale.batch.inc, line 184
Code
function locale_translation_batch_fetch_download($project, $langcode, &$context) {
$sources = locale_translation_get_status([
$project,
], [
$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 %langcode translation for %project.', [
'%langcode' => $langcode,
'%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];
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.