function locale_system_remove

Same name and namespace in other branches
  1. 10 core/modules/locale/locale.module \locale_system_remove()
  2. 11.x core/modules/locale/locale.module \locale_system_remove()
  3. 9 core/modules/locale/locale.module \locale_system_remove()
  4. 8.9.x 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.

Deprecated

in drupal:11.5.0 and is removed from drupal:13.0.0. There is no replacement.

See also

https://www.drupal.org/node/3595086

File

core/modules/locale/locale.module, line 288

Code

function locale_system_remove($components) : void {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3595086', E_USER_DEPRECATED);
  $components += [
    'module' => [],
    'theme' => [],
  ];
  $list = array_merge($components['module'], $components['theme']);
  if (locale_translatable_language_list()) {
    $module_handler = \Drupal::moduleHandler();
    $module_handler->loadInclude('locale', 'inc', 'locale.compare');
    $module_handler->loadInclude('locale', 'inc', 'locale.bulk');
    // 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(\Drupal::service(LocaleProjectRepository::class)->getAll());
    if ($list = array_intersect($list, $projects)) {
      // Remove translation files.
      \Drupal::service(LocaleFileManager::class)->deleteTranslationFiles($list, []);
      // Remove translatable projects.
      \Drupal::service(LocaleProjectRepository::class)->deleteMultiple($list);
      // Clear the translation status.
      \Drupal::service(LocaleSource::class)->deleteSources($list);
    }
  }
}

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