You are here

function locale_languages_delete_form_submit in Drupal 7

Same name and namespace in other branches
  1. 6 includes/locale.inc \locale_languages_delete_form_submit()

Process language deletion submissions.

Related topics

File

modules/locale/locale.admin.inc, line 461
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_delete('locales_target')
      ->condition('language', $form_state['values']['langcode'])
      ->execute();
    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_delete('languages')
      ->condition('language', $form_state['values']['langcode'])
      ->execute();
    db_update('node')
      ->fields(array(
      'language' => '',
    ))
      ->condition('language', $form_state['values']['langcode'])
      ->execute();
    if ($languages[$form_state['values']['langcode']]->enabled) {
      variable_set('language_count', variable_get('language_count', 1) - 1);
    }
    module_invoke_all('multilingual_settings_changed');
    $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/config/regional/language';
  return;
}