You are here

function locale_system_remove in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/locale/locale.module \locale_system_remove()

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 $components: An array of arrays of component (theme and/or module) names to import translations for, indexed by type.

2 calls to locale_system_remove()
locale_module_preuninstall in core/modules/locale/locale.module
Implements hook_module_preuninstall().
locale_themes_uninstalled in core/modules/locale/locale.module
Implements hook_themes_uninstalled().

File

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

Code

function locale_system_remove($components) {
  $components += [
    'module' => [],
    'theme' => [],
  ];
  $list = array_merge($components['module'], $components['theme']);
  if ($language_list = locale_translatable_language_list()) {
    module_load_include('compare.inc', 'locale');
    \Drupal::moduleHandler()
      ->loadInclude('locale', 'bulk.inc');

    // Only when projects are removed, the translation files and records will be
    // deleted. Not each disabled module will remove a project, e.g., sub
    // modules.
    $projects = array_keys(locale_translation_get_projects());
    if ($list = array_intersect($list, $projects)) {
      locale_translation_file_history_delete($list);

      // Remove translation files.
      locale_translate_delete_translation_files($list, []);

      // Remove translatable projects.
      // Follow-up issue https://www.drupal.org/node/1842362 to replace the
      // {locale_project} table. Then change this to a function call.
      \Drupal::service('locale.project')
        ->deleteMultiple($list);

      // Clear the translation status.
      locale_translation_status_delete_projects($list);
    }
  }
}