function LocaleFetch::buildUpdateBatch
Same name and namespace in other branches
- 11.x core/modules/locale/src/LocaleFetch.php \Drupal\locale\LocaleFetch::buildUpdateBatch()
Builds a batch to check, download and import project translations.
Parameters
array $projects: Array of project names for which to update the translations. Defaults to all translatable projects.
array $langcodes: Array of language codes. Defaults to all translatable languages.
array $options: Array of import options. See \Drupal\locale\LocaleImportBatch::buildBatch().
Return value
array Batch definition array.
File
-
core/
modules/ locale/ src/ LocaleFetch.php, line 45
Class
- LocaleFetch
- Provides the locale fetch services.
Namespace
Drupal\localeCode
public function buildUpdateBatch(array $projects = [], array $langcodes = [], array $options = []) : array {
$projects = $projects ?: array_keys($this->localeProjectRepository
->getAll());
$langcodes = $langcodes ?: array_keys(locale_translatable_language_list());
$status_options = $options;
$status_options['finish_feedback'] = FALSE;
$batch_builder = (new BatchBuilder())->setTitle($this->t('Updating translations'))
->setErrorMessage($this->t('Error importing translation files'))
->setFinishCallback(self::class . ':batchFinished');
// Check status of local and remote translation files.
$operations = $this->getStatusOperations($projects, $langcodes, $status_options);
// Download and import translations.
$operations = array_merge($operations, $this->getFetchOperations($projects, $langcodes, $options));
foreach ($operations as $operation) {
$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.