function LocaleExtensionHooks::deleteTranslationHistory

Same name and namespace in other branches
  1. main core/modules/locale/src/Hook/LocaleExtensionHooks.php \Drupal\locale\Hook\LocaleExtensionHooks::deleteTranslationHistory()

Delete translation history of modules and themes.

Only the translation history is removed, not the source strings or translations. This is not possible because strings are shared between modules and we have no record of which string is used by which module.

Parameters

array $extensions: An array of arrays of component (theme and/or module) names to import translations for, indexed by type.

2 calls to LocaleExtensionHooks::deleteTranslationHistory()
LocaleExtensionHooks::modulePreuninstall in core/modules/locale/src/Hook/LocaleExtensionHooks.php
Implements hook_module_preuninstall().
LocaleExtensionHooks::themesUninstalled in core/modules/locale/src/Hook/LocaleExtensionHooks.php
Implements hook_themes_uninstalled().

File

core/modules/locale/src/Hook/LocaleExtensionHooks.php, line 94

Class

LocaleExtensionHooks
Extension hook implementations for locale.

Namespace

Drupal\locale\Hook

Code

protected function deleteTranslationHistory(array $extensions) : void {
  if (locale_translatable_language_list()) {
    // Only when projects are removed, the translation files and records will
    // be deleted. Not every uninstalled module will remove a project, e.g.,
    // sub modules.
    $projects = array_keys($this->localeProjectRepository
      ->getAll());
    if ($extensions = array_intersect($extensions, $projects)) {
      // Remove translation files.
      $this->localeFileManager
        ->deleteTranslationFiles($extensions, []);
      // Remove translatable projects.
      $this->localeProjectRepository
        ->deleteMultiple($extensions);
      // Clear the translation status.
      $this->localeSource
        ->deleteSources($extensions);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.