Problem/Motivation

On a multilingual system, when referencing and selecting an entity, the node edit form display shows this selected entity on its default language.

Steps to Reproduce

1. Create a "Node 1" in two languages, for example "NL" and "EN".
2. Create a "Node 2" in two languages, for example "NL" and "EN".
2. Edit "Node 1" and reference "Node 2" in both languages.

Expected Result on "Node 1" edit form set to "NL" language:

"Node 2" should show either the selected node language or the context language which, in this case, is NL.

Actual result on node "Node 1" edit form set to "NL" language:

"Node 2" shows the default language title, "EN".

Proposed solution

Update EntityBrowserElement where entity is loaded and add \Drupal::service('entity.repository')->getTranslationFromContext($entity);

Comments

rutiolma created an issue. See original summary.

rutiolma’s picture

StatusFileSize
new690 bytes

This approach uses Entity Repository service to get the contextual language of the entity.
Besides the above mentioned issue, this should fix the entity display on other places since this function is called in other places.

This is in someway related with #2820478 and it seems the best approach considering that EB only gets entity_type:id, not the langcode.

oknate’s picture

Issue summary: View changes
oknate’s picture

Issue summary: View changes
oknate’s picture

StatusFileSize
new2.29 MB

Here's a video example of the bug, I'm editing the French version of node 1, and whether I select the English or French, it always shows the English title.

oknate’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new1.9 MB

Marking RTBC. Here's a video example of the fix. It now shows the language from the context. In other words, if you're editing the French translation, it will show the French translation, if available.

  • oknate committed c18787e on 8.x-2.x authored by rutiolma
    Issue #3019943 by rutiolma: Language aware entity in form display
    

  • oknate committed a7dbb0b on 8.x-1.x authored by rutiolma
    Issue #3019943 by rutiolma: Language aware entity in form display
    
oknate’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.