diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php index e86495e..0b868cd 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php @@ -29,13 +29,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->getEntity(); if ($entity->isDefaultTranslation()) { - $languages = []; - foreach ($entity->getTranslationLanguages() as $language) { - $languages[] = $language->getName(); - } + if (count($entity->getTranslationLanguages()) > 1) { + $languages = []; + foreach ($entity->getTranslationLanguages() as $language) { + $languages[] = $language->getName(); + } - if (count($languages) > 1) { - $form['entity_deletes'] = array( + $form['deleted_translations'] = array( '#theme' => 'item_list', '#title' => $this->t('The following @entity-type translations will be deleted:', [ '@entity-type' => $entity->getEntityType()->getLowercaseLabel() diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 4a71db7..8f64974 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -279,11 +279,9 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s } $entity = $form_object->getEntity(); - if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1) { - if ($form_object->getOperation() != 'delete') { - $controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation'); - $controller->entityFormAlter($form, $form_state, $entity); - } + if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && $form_object->getOperation() != 'delete') { + $controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation'); + $controller->entityFormAlter($form, $form_state, $entity); // @todo Move the following lines to the code generating the property form // elements once we have an official #multilingual FAPI key. diff --git a/core/modules/system/src/Tests/Entity/EntityFormTest.php b/core/modules/system/src/Tests/Entity/EntityFormTest.php index 7edde9f..e4365eb 100644 --- a/core/modules/system/src/Tests/Entity/EntityFormTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFormTest.php @@ -132,7 +132,7 @@ protected function doTestMultilingualFormCRUD($entity_type_id) { $this->drupalGet('ro/' . $entity_type_id . '/manage/' . $entity->id()); $this->clickLink(t('Delete')); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->drupalPostForm(NULL, array(), t('Delete Romanian translation')); $entity = $this->loadEntityByName($entity_type_id, $name1); $this->assertNotNull($entity, format_string('%entity_type: The original entity still exists.', array('%entity_type' => $entity_type_id))); $this->assertFalse($entity->hasTranslation('ro'), format_string('%entity_type: Entity translation does not exist anymore.', array('%entity_type' => $entity_type_id)));