You are here

function _drush_l10n_update_get_updates in Localization update 7.2

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

Helper function to obtain $updates.

Return value

array|null Array of projects and languages to be updated. Array keys:

  • projects: Associative array of projects to be updated. Key: Project name. Value: Project info array.
  • languages: Associative array of languages to be updated. Key: Language code. Value: Project info array.
1 call to _drush_l10n_update_get_updates()
drush_l10n_update in ./l10n_update.drush.inc
Callback for command l10n-update.

File

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

Code

function _drush_l10n_update_get_updates() {
  $updates = array();
  $languages = l10n_update_translatable_language_list();
  $status = l10n_update_get_status();
  drush_log(dt('Fetching update information for all projects / all languages.'), 'status');

  // Prepare information about projects which have available translation
  // updates.
  if ($languages && $status) {
    foreach ($status as $project) {
      foreach ($project as $langcode => $project_info) {

        // Translation update found for this project-language combination.
        if ($project_info->type && ($project_info->type == L10N_UPDATE_LOCAL || $project_info->type == L10N_UPDATE_REMOTE)) {
          $updates['projects'][$project_info->name] = $project_info;
          $updates['languages'][$langcode] = $project_info;
        }
      }
    }
    if ($updates) {
      return $updates;
    }
    else {
      drush_log(dt('All project translations up to date.'), 'status');
    }
  }
  else {
    if (empty($languages)) {
      drush_log(dt('No languages to update.'), 'warning');
    }
    else {
      drush_log(dt('No translation status available. Run drush l10n-update-status first.'), 'warning');
    }
  }
}