function LocaleProjectRepository::prepareProjectList

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

Prepare module and theme data.

Modify .info.yml file data before it is processed by \Drupal\Core\Utility\ProjectInfo->processInfoList(). In order for \Drupal\Core\Utility\ProjectInfo->processInfoList() to recognize a project, it requires the 'project' parameter in the .info.yml file data.

Custom modules or themes can bring their own gettext translation file. To enable import of this file, the module or theme defines "interface translation project = my_project" in its .info.yml file. This method will add a project "my_project" to the info data.

Parameters

\Drupal\Core\Extension\Extension[] $data: Array of .info.yml file data.

Return value

array Array of .info.yml file data.

File

core/modules/locale/src/LocaleProjectRepository.php, line 230

Class

LocaleProjectRepository
Provides storage and rebuilding of locale project information.

Namespace

Drupal\locale

Code

protected function prepareProjectList(array $data) : array {
  foreach ($data as $name => $file) {
    // Include interface translation projects. To allow
    // \Drupal\Core\Utility\ProjectInfo->processInfoList() to identify this
    // as a project, the 'project' property is filled with the
    // 'interface translation project' value.
    if (isset($file->info['interface translation project'])) {
      $data[$name]->info['project'] = $file->info['interface translation project'];
    }
  }
  return $data;
}

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