function locale_translation_batch_fetch_build
Same name in other branches
- 8.9.x core/modules/locale/locale.fetch.inc \locale_translation_batch_fetch_build()
- 10 core/modules/locale/locale.fetch.inc \locale_translation_batch_fetch_build()
- 11.x core/modules/locale/locale.fetch.inc \locale_translation_batch_fetch_build()
Builds a batch to download and import project translations.
Parameters
array $projects: Array of project names for which to check the state of translation files. Defaults to all translatable projects.
array $langcodes: Array of language codes. Defaults to all translatable languages.
array $options: Array of import options. See locale_translate_batch_import_files().
Return value
array Batch definition array.
1 call to locale_translation_batch_fetch_build()
- TranslationStatusForm::submitForm in core/
modules/ locale/ src/ Form/ TranslationStatusForm.php - Form submission handler.
File
-
core/
modules/ locale/ locale.fetch.inc, line 68
Code
function locale_translation_batch_fetch_build($projects = [], $langcodes = [], $options = []) {
$projects = $projects ? $projects : array_keys(locale_translation_get_projects());
$langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
$batch_builder = (new BatchBuilder())->setTitle(t('Updating translations.'))
->setErrorMessage(t('Error importing translation files'))
->setFile(\Drupal::service('extension.list.module')->getPath('locale') . '/locale.batch.inc')
->setFinishCallback('locale_translation_batch_fetch_finished');
$operations = _locale_translation_fetch_operations($projects, $langcodes, $options);
array_walk($operations, function ($operation) use ($batch_builder) {
call_user_func_array([
$batch_builder,
'addOperation',
], $operation);
});
return $batch_builder->toArray();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.