diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index a6fcb2e0f0ee3b8ad7b6eb219609696ef2ac9c61..77d687f2fa8e1eda059baeea6c3de6a4d99de3e3 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -363,7 +363,13 @@ public function getParentComment() { * {@inheritdoc} */ public function getCommentedEntity() { - return $this->get('entity_id')->entity; + $language = $this->language()->getId(); + /** @var \Drupal\Core\Entity\EntityInterface $entity */ + $entity = $this->get('entity_id')->entity; + if ($entity?->hasTranslation($language)) { + return $entity->getTranslation($language); + } + return $entity; } /** diff --git a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php index 5da8ea42e10e00133eea43c76b16761f3d2f1599..2776458fdf23cff7260f7787fc21b0fa1d3b0b72 100644 --- a/core/modules/comment/tests/src/Functional/CommentLanguageTest.php +++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php @@ -162,6 +162,15 @@ public function testCommentLanguage(): void { $this->assertSession()->responseContains($value); } } + + $this->drupalGet('admin/content/comment'); + $comment_links = $this->xpath('//td[contains(@class, "views-field-subject")]//a'); + + foreach ($comment_links as $link) { + $this->clickLink($link->getText()); + $this->assertSession()->statusCodeEquals(200); + $this->drupalGet('admin/content/comment'); + } } }