function LocaleFetch::fetchOperations

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

Helper function to construct the batch operations to fetch 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.

Return value

array Array of batch operations.

2 calls to LocaleFetch::fetchOperations()
LocaleFetch::batchFetchBuild in core/modules/locale/src/LocaleFetch.php
Builds a batch to download and import project translations.
LocaleFetch::batchUpdateBuild in core/modules/locale/src/LocaleFetch.php
Builds a batch to check, download and import project translations.

File

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

Class

LocaleFetch
Provides the locale source services.

Namespace

Drupal\locale

Code

protected function fetchOperations(array $projects, array $langcodes, array $options) : array {
  $operations = [];
  foreach ($projects as $project) {
    foreach ($langcodes as $langcode) {
      if (locale_translation_use_remote_source()) {
        $operations[] = [
          'locale_translation_batch_fetch_download',
          [
            $project,
            $langcode,
          ],
        ];
      }
      $operations[] = [
        'locale_translation_batch_fetch_import',
        [
          $project,
          $langcode,
          $options,
        ],
      ];
    }
  }
  return $operations;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.