function LocaleFetch::batchFetchBuild
Same name and namespace in other branches
- main core/modules/locale/src/LocaleFetch.php \Drupal\locale\LocaleFetch::batchFetchBuild()
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_build().
Return value
array Batch definition array.
File
-
core/
modules/ locale/ src/ LocaleFetch.php, line 72
Class
- LocaleFetch
- Provides the locale source services.
Namespace
Drupal\localeCode
public function batchFetchBuild(array $projects = [], array $langcodes = [], array $options = []) : array {
$projects = $projects ?: array_keys($this->projectStorage
->getProjects());
$langcodes = $langcodes ?: array_keys(locale_translatable_language_list());
$batch_builder = (new BatchBuilder())->setTitle($this->t('Updating translations.'))
->setErrorMessage($this->t('Error importing translation files'))
->setFile($this->moduleExtensionList
->getPath('locale') . '/locale.batch.inc')
->setFinishCallback('locale_translation_batch_fetch_finished');
$operations = $this->fetchOperations($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.