function LocaleFetch::buildFetchBatch

Same name and namespace in other branches
  1. main core/modules/locale/src/LocaleFetch.php \Drupal\locale\LocaleFetch::buildFetchBatch()

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 \Drupal\locale\LocaleImportBatch::buildBatch().

Return value

array Batch definition array.

File

core/modules/locale/src/LocaleFetch.php, line 81

Class

LocaleFetch
Provides the locale fetch services.

Namespace

Drupal\locale

Code

public function buildFetchBatch(array $projects = [], array $langcodes = [], array $options = []) : array {
  $projects = $projects ?: array_keys($this->localeProjectRepository
    ->getAll());
  $langcodes = $langcodes ?: array_keys(locale_translatable_language_list());
  $batch_builder = (new BatchBuilder())->setTitle($this->t('Updating translations.'))
    ->setErrorMessage($this->t('Error importing translation files'))
    ->setFinishCallback(self::class . ':batchFinished');
  $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.