You are here

function i18nstrings_admin_refresh_submit in Internationalization 6

Form submission.

File

i18nstrings/i18nstrings.admin.inc, line 58
Admin page callbacks for the i18nstrings module.

Code

function i18nstrings_admin_refresh_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  $groups = array_filter($form_state['values']['groups']);
  $languages = array_filter($form_state['values']['languages']);
  $group_names = module_invoke_all('locale', 'groups');
  if ($op == t('Refresh strings') && $groups) {
    foreach ($groups as $group) {
      if (i18nstrings_refresh_group($group, TRUE)) {
        drupal_set_message(t("Successfully refreshed strings for %group", array(
          '%group' => $group_names[$group],
        )));
      }
      else {
        drupal_set_message(t("Cannot refresh strings for %group.", array(
          '%group' => $group_names[$group],
        )), 'warning');
      }
    }
  }
  elseif ($op == t('Update translations') && $groups && $languages) {
    $count = 0;
    foreach ($languages as $language) {
      $count += i18nstrings_admin_update($language, $groups);
    }
    drupal_set_message(format_plural($count, '1 string has been updated.', '@count strings have been updated.'));
  }
}