You are here

function locale_configurable_language_delete in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.module \locale_configurable_language_delete()
  2. 10 core/modules/locale/locale.module \locale_configurable_language_delete()

Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.

File

core/modules/locale/locale.module, line 229
Enables the translation of the user interface to languages other than English.

Code

function locale_configurable_language_delete(ConfigurableLanguageInterface $language) {

  // Remove translations.
  \Drupal::service('locale.storage')
    ->deleteTranslations([
    'language' => $language
      ->id(),
  ]);

  // Remove interface translation files.
  module_load_include('inc', 'locale', 'locale.bulk');
  locale_translate_delete_translation_files([], [
    $language
      ->id(),
  ]);

  // Remove translated configuration objects.
  Locale::config()
    ->deleteLanguageTranslations($language
    ->id());

  // Changing the language settings impacts the interface:
  _locale_invalidate_js($language
    ->id());
  \Drupal::cache('render')
    ->deleteAll();

  // Clear locale translation caches.
  locale_translation_status_delete_languages([
    $language
      ->id(),
  ]);
  \Drupal::cache()
    ->delete('locale:' . $language
    ->id());
}