You are here

function locale_languages_delete_form_submit in Drupal 6

Same name and namespace in other branches
  1. 7 modules/locale/locale.admin.inc \locale_languages_delete_form_submit()

Process language deletion submissions.

Related topics

File

includes/locale.inc, line 423
Administration functions for locale.module.

Code

function locale_languages_delete_form_submit($form, &$form_state) {
  $languages = language_list();
  if (isset($languages[$form_state['values']['langcode']])) {

    // Remove translations first.
    db_query("DELETE FROM {locales_target} WHERE language = '%s'", $form_state['values']['langcode']);
    cache_clear_all('locale:' . $form_state['values']['langcode'], 'cache');

    // With no translations, this removes existing JavaScript translations file.
    _locale_rebuild_js($form_state['values']['langcode']);

    // Remove the language.
    db_query("DELETE FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']);
    db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_state['values']['langcode']);
    $variables = array(
      '%locale' => $languages[$form_state['values']['langcode']]->name,
    );
    drupal_set_message(t('The language %locale has been removed.', $variables));
    watchdog('locale', 'The language %locale has been removed.', $variables);
  }

  // Changing the language settings impacts the interface:
  cache_clear_all('*', 'cache_page', TRUE);
  $form_state['redirect'] = 'admin/settings/language';
  return;
}