You are here

function l10n_update_project_refresh in Localization update 7

Same name and namespace in other branches
  1. 6 l10n_update.project.inc \l10n_update_project_refresh()

Refresh projects after enabling modules

When new projects are installed, set a batch for locale import / update

Parameters

$modules: Array of module names.

1 call to l10n_update_project_refresh()
l10n_update_modules_enabled in ./l10n_update.module
Implements hook_modules_enabled().

File

./l10n_update.project.inc, line 128
Library for querying Drupal projects

Code

function l10n_update_project_refresh($modules) {
  module_load_include('check.inc', 'l10n_update');
  $projects = array();

  // Get all current projects, including the recently installed.
  $current_projects = l10n_update_build_projects(TRUE);

  // Collect project data of newly installed projects.
  foreach ($modules as $name) {
    if (isset($current_projects[$name])) {
      $projects[$name] = $current_projects[$name];
    }
  }

  // If a translation is available and if update is required, lets go.
  if ($projects && ($available = l10n_update_check_projects($projects))) {
    $history = l10n_update_get_history();
    if ($updates = l10n_update_build_updates($history, $available)) {
      module_load_include('batch.inc', 'l10n_update');

      // Filter out updates in other languages. If no languages, all of them will be updated
      $updates = _l10n_update_prepare_updates($updates);
      $batch = l10n_update_batch_multiple($updates, variable_get('l10n_update_import_mode', LOCALE_IMPORT_KEEP));
      batch_set($batch);
    }
  }
}