You are here

function locale_uninstall in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.install \locale_uninstall()
  2. 5 modules/locale/locale.install \locale_uninstall()
  3. 6 modules/locale/locale.install \locale_uninstall()
  4. 9 core/modules/locale/locale.install \locale_uninstall()
  5. 10 core/modules/locale/locale.install \locale_uninstall()

Implements hook_uninstall().

File

modules/locale/locale.install, line 224
Install, update and uninstall functions for the locale module.

Code

function locale_uninstall() {

  // Delete all JavaScript translation files.
  $locale_js_directory = 'public://' . variable_get('locale_js_directory', 'languages');
  if (is_dir($locale_js_directory)) {
    $files = db_query('SELECT language, javascript FROM {languages}');
    foreach ($files as $file) {
      if (!empty($file->javascript)) {
        file_unmanaged_delete($locale_js_directory . '/' . $file->language . '_' . $file->javascript . '.js');
      }
    }

    // Delete the JavaScript translations directory if empty.
    if (!file_scan_directory($locale_js_directory, '/.*/')) {
      drupal_rmdir($locale_js_directory);
    }
  }

  // Clear variables.
  variable_del('language_default');
  variable_del('language_count');
  variable_del('language_types');
  variable_del('locale_language_negotiation_url_part');
  variable_del('locale_language_negotiation_session_param');
  variable_del('language_content_type_default');
  variable_del('language_content_type_negotiation');
  variable_del('locale_cache_strings');
  variable_del('locale_js_directory');
  variable_del('javascript_parsed');
  variable_del('locale_field_language_fallback');
  variable_del('locale_cache_length');
  foreach (language_types() as $type) {
    variable_del("language_negotiation_{$type}");
    variable_del("locale_language_providers_weight_{$type}");
  }
  foreach (node_type_get_types() as $type => $content_type) {
    $setting = variable_del("language_content_type_{$type}");
  }

  // Switch back to English: with a $language->language value different from 'en'
  // successive calls of t() might result in calling locale(), which in turn might
  // try to query the unexisting {locales_source} and {locales_target} tables.
  drupal_language_initialize();
}