You are here

function lingotek_check_for_l10n_translations in Lingotek Translation 7.4

Same name and namespace in other branches
  1. 7.5 lingotek.admin.inc \lingotek_check_for_l10n_translations()
2 calls to lingotek_check_for_l10n_translations()
lingotek_admin_load_l10n_update_batch in ./lingotek.admin.inc
lingotek_form_bulk_sync in ./lingotek.sync.inc

File

./lingotek.admin.inc, line 806

Code

function lingotek_check_for_l10n_translations($modules) {

  // return the translations available through Drupal translation and a list of the ones still needed
  module_load_include('project.inc', 'l10n_update');
  module_load_include('check.inc', 'l10n_update');
  $projects = array();
  $available = array();
  $updates = 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 $k => $v) {
    if (isset($current_projects[$k])) {
      $projects[$k] = $current_projects[$k];
    }
  }

  // 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);
    }
  }
  return $updates;
}