You are here

function l10n_update_update_7207 in Localization update 7.2

Migrate D8 style plurals to D7 style.

File

./l10n_update.install, line 584
Install file for l10n remote updates.

Code

function l10n_update_update_7207(&$sandbox) {
  $message = NULL;
  $batch_size = 50;
  if (!isset($sandbox['progress'])) {
    $sandbox['progress'] = 0;
    $sandbox['max'] = count(l10n_update_get_d8_plural_strings());
    $sandbox['report'] = array();
  }
  if ($sandbox['max'] == 0) {
    $sandbox['#finished'] = 1;
    return NULL;
  }
  $finished = l10n_update_d8_plural_conversion($sandbox['progress'], $batch_size, $sandbox['report']);
  $sandbox['progress'] += $batch_size;

  // Whether the batch is finished is determined by the result of
  // l10n_update_d8_plural_conversion().The progress (percentage) is
  // calculated.
  if (empty($sandbox['max']) || $finished) {
    $sandbox['#finished'] = 1;
  }
  else {
    $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max'];
  }
  if ($sandbox['#finished'] == 1) {
    if (!empty($sandbox['report']['results'])) {
      l10n_update_finish_d8_plural_strings($sandbox['report']['results']);
    }
    if (!empty($sandbox['report']['writer']['skips'])) {
      $message = t('Some problems were reported during plural string migration. See <a href="/admin/reports/dblog">Recent log messages</a> for details.');
    }
  }
  return $message;
}