diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php index 694f443..39eb27c 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\PathBasedGeneratorInterface; +use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -29,16 +30,26 @@ class LanguageDeleteForm extends EntityConfirmFormBase implements EntityControll protected $urlGenerator; /** + * The translation manager service. + * + * @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface + */ + protected $translator; + + /** * Constructs a new LanguageDeleteForm object. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler service. * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator * The url generator service. + * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translator + * The translation manager. */ - public function __construct(ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator) { + public function __construct(ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator, TranslatorInterface $translator) { parent::__construct($module_handler); $this->urlGenerator = $url_generator; + $this->translator = $translator; } /** @@ -47,7 +58,8 @@ public function __construct(ModuleHandlerInterface $module_handler, PathBasedGen public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) { return new static( $container->get('module_handler'), - $container->get('url_generator') + $container->get('url_generator'), + $container->get('string_translation') ); } @@ -55,7 +67,7 @@ public static function createInstance(ContainerInterface $container, $entity_typ * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete the language %language?', array('%language' => $this->entity->get('label'))); + return $this->translator->translate('Are you sure you want to delete the language %language?', array('%language' => $this->entity->label())); } /** @@ -69,14 +81,14 @@ public function getCancelPath() { * {@inheritdoc} */ public function getDescription() { - return t('Deleting a language will remove all interface translations associated with it, and content in this language will be set to be language neutral. This action cannot be undone.'); + return $this->translator->translate('Deleting a language will remove all interface translations associated with it, and content in this language will be set to be language neutral. This action cannot be undone.'); } /** * {@inheritdoc} */ public function getConfirmText() { - return t('Delete'); + return $this->translator->translate('Delete'); } /** @@ -95,7 +107,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU // Warn and redirect user when attempting to delete the default language. if (language_default()->id == $langcode) { - drupal_set_message(t('The default language cannot be deleted.')); + drupal_set_message($this->translator->translate('The default language cannot be deleted.')); $url = $this->urlGenerator->generateFromPath('admin/config/regional/language', array('absolute' => TRUE)); return new RedirectResponse($url); } @@ -112,13 +124,16 @@ public function buildForm(array $form, array &$form_state, Request $request = NU * {@inheritdoc} */ public function submit(array $form, array &$form_state) { + // @todo This should be replaced with $this->entity->delete() when the + // additional logic in language_delete() is ported. $success = language_delete($this->entity->id()); if ($success) { - $t_args = array('%language' => $this->entity->get('label'), '%langcode' => $this->entity->id()); - drupal_set_message(t('The %language (%langcode) language has been removed.', $t_args)); + $options = array('%language' => $this->entity->label(), '%langcode' => $this->entity->id()); + drupal_set_message($this->translator->translate('The %language (%langcode) language has been removed.', $options)); } $form_state['redirect'] = 'admin/config/regional/language'; } + }