function locale_translation_get_projects

locale_translation_get_projects(array $project_names = array())

Get array of projects which are available for interface translation.

This project data contains all projects which will be checked for available interface translations.

For full functionality this function depends on Update module. When Update module is enabled the project data will contain the most recent module status; both in enabled status as in version. When Update module is disabled this function will return the last known module state. The status will only be updated once Update module is enabled.

Parameters

array $project_names: Array of names of the projects to get.

Return value

array Array of project data for translation update.

See also

locale_translation_build_projects()

File

core/modules/locale/locale.translation.inc, line 55
Common API for interface translation.

Code

function locale_translation_get_projects(array $project_names = array()) {
  $projects = &drupal_static(__FUNCTION__, array());

  if (empty($projects)) {
    // Get project data from the database.
    $row_count = \Drupal::service('locale.project')->countProjects();
    // https://www.drupal.org/node/1777106 is a follow-up issue to make the
    // check for possible out-of-date project information more robust.
    if ($row_count == 0) {
      module_load_include('compare.inc', 'locale');
      // At least the core project should be in the database, so we build the
      // data if none are found.
      locale_translation_build_projects();
    }
    $projects = \Drupal::service('locale.project')->getAll();
    array_walk($projects, function(&$project) {
      $project = (object) $project;
    });
  }

  // Return the requested project names or all projects.
  if ($project_names) {
    return array_intersect_key($projects, array_combine($project_names, $project_names));
  }
  return $projects;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!locale!locale.translation.inc/function/locale_translation_get_projects/8.1.x