function LocaleSource::loadSources

Loads cached translation sources containing current translation status.

Parameters

array $projects: Array of project names. Defaults to all translatable projects.

array $langcodes: Array of language codes. Defaults to all translatable languages.

Return value

array Array of source objects. Keyed with <project name>:<language code>.

See also

sourceBuild()

File

core/modules/locale/src/LocaleSource.php, line 33

Class

LocaleSource
Provides the locale source services.

Namespace

Drupal\locale

Code

public function loadSources(?array $projects = NULL, ?array $langcodes = NULL) : array {
  $sources = [];
  $projects = $projects ?: array_keys($this->projectStorage
    ->getProjects());
  $langcodes = $langcodes ?: array_keys(locale_translatable_language_list());
  // Load source data from locale_translation_status cache.
  $status = locale_translation_get_status();
  // Use only the selected projects and languages for update.
  foreach ($projects as $project) {
    foreach ($langcodes as $langcode) {
      $sources[$project][$langcode] = $status[$project][$langcode] ?? NULL;
    }
  }
  return $sources;
}

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