You are here

function drush_l10n_update_status in Localization update 7

Same name and namespace in other branches
  1. 6 l10n_update.drush.inc \drush_l10n_update_status()
  2. 7.2 l10n_update.drush.inc \drush_l10n_update_status()

Callback for command l10n-update-status.

File

./l10n_update.drush.inc, line 55
Drush interface to l10n-update functionalities.

Code

function drush_l10n_update_status() {
  $updates = _drush_l10n_update_get_updates();
  if (!is_null($updates)) {
    $languages = drush_get_option('languages');

    // Table header.
    $table = array();
    $header = array(
      dt('Project'),
    );
    foreach ($languages as $lang => $language) {
      $header[] = $language . ' status';
    }
    $table[] = $header;

    // Iterate projects to obtain per language status.
    $projects = l10n_update_get_projects();
    $history = l10n_update_get_history();
    foreach ($projects as $name => $project) {
      $row = array();

      // Project.
      $title = isset($project->title) ? $project->title : $project->name;
      $row[] = $title . ' ' . $project->version;

      // Language status.
      foreach ($languages as $lang => $language) {
        $current = isset($history[$name][$lang]) ? $history[$name][$lang] : NULL;
        $update = isset($updates[$name][$lang]) ? $updates[$name][$lang] : NULL;
        if ($update) {
          $row[] = $update->type == 'download' ? t('Remote update available') : t('Local update available');
        }
        elseif ($current) {
          $row[] = t('Up to date');
        }
        else {
          $row[] = t('No information');
        }
      }
      $table[] = $row;
    }
    drush_print_table($table, TRUE);
  }
  else {
    drush_log(dt('No projects or languages to update.'), 'ok');
  }
}