Translated entity doesn't show up for the referenced item

Created on 10 March 2023, over 1 year ago
Updated 10 May 2024, about 2 months ago

Problem/Motivation

On translations, the referenced entity shows the default original version instead of the translated version.

Steps to reproduce

  1. Create an English node A.
  2. Set another English node B as a reference for an entity_reference_display field from node A.
  3. Create a German translation for node B
  4. Create a German translation for node A leaving the entity reference field as it is with auto populated reference as German B translation.
  5. On node A English page, I see node B being rendered using the expected view mode.
  6. But on node A german page, I don't see the German B rendered fro the entity reference field but still see English B as rendered.

Proposed resolution

The issue is because $items->getEntity(); from EntityReferenceDisplayFormatterTrait gets the original source entity instead of the relevant translation. This is also highlighted for getEntity() method from Drupal core FieldItemListInterface to use translation methods to force getting the translation for the context, https://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/lib/Drupal/C....

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

fathima.asmat London, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024