diff -u b/core/modules/system/src/Form/ModulesUninstallForm.php b/core/modules/system/src/Form/ModulesUninstallForm.php --- b/core/modules/system/src/Form/ModulesUninstallForm.php +++ b/core/modules/system/src/Form/ModulesUninstallForm.php @@ -14,6 +14,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\StringTranslation\TranslationInterface; /** * Provides a form for uninstalling modules. @@ -42,13 +43,21 @@ protected $keyValueExpirable; /** + * The string translation manager. + * + * @var \Drupal\Core\StringTranslation\TranslationInterface + */ + protected $stringTranslation; + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('module_handler'), $container->get('module_installer'), - $container->get('keyvalue.expirable')->get('modules_uninstall') + $container->get('keyvalue.expirable')->get('modules_uninstall'), + $container->get('string_translation') ); } @@ -61,11 +70,14 @@ * The module installer. * @param \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable * The key value expirable factory. + * @param \Drupal\Core\StringTranslation\TranslationInterface $stringTranslation + * The string translation manager. */ - public function __construct(ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, KeyValueStoreExpirableInterface $key_value_expirable) { + public function __construct(ModuleHandlerInterface $module_handler, ModuleInstallerInterface $module_installer, KeyValueStoreExpirableInterface $key_value_expirable, TranslationInterface $stringTranslation) { $this->moduleHandler = $module_handler; $this->moduleInstaller = $module_installer; $this->keyValueExpirable = $key_value_expirable; + $this->stringTranslation = $stringTranslation; } /** @@ -162,7 +174,7 @@ } } if (!empty($required_modules)) { - $disabled_message = \Drupal::translation()->formatPlural(count($required_modules), + $disabled_message = $this->stringTranslation->formatPlural(count($required_modules), 'To uninstall @module, the following module must be uninstalled first: @required_modules', 'To uninstall @module, the following modules must be uninstalled first: @required_modules', array('@module' => $module->getName(), '@required_modules' => SafeMarkup::checkAdminXss(implode(', ', $required_modules)))); @@ -172,7 +184,7 @@ $disabled_message = ''; } if (isset($validation_reasons[$module_key])) { - $disabled_message = \Drupal::translation()->formatPlural(count($validation_reasons[$module_key]), + $disabled_message = $this->stringTranslation->formatPlural(count($validation_reasons[$module_key]), 'The following reason prevents @module from being uninstalled: @reasons', 'The following reasons prevent @module from being uninstalled: @reasons', array('@module' => $module->getName(), '@reasons' => SafeMarkup::checkAdminXss(implode('; ', $validation_reasons[$module_key]))));