Is it correct to say that when embedding an entity in a field on a parent entity, the embedded entity should be rendered in the same translation language as the parent (if available)?
Currently it seems data-langcode is set correctly in $context but not applied to translate the embedded entity. Patch attached translates the entity as part of EntityEmbedBuilder->buildEntityEmbed(). There's a @todo comment relating to deciding what to do if the embedded entity has no translation in the parent's language - perhaps this could be a configurable setting? i.e. display base language entity, or hide?
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3027445-7.patch | 3.02 KB | wim leers |
| #7 | interdiff.txt | 2.19 KB | wim leers |
| #6 | 3027445-6.patch | 2.13 KB | wim leers |
| #2 | 3027445-entity_embed-translate_entity.patch | 1.3 KB | bgilhome |
Comments
Comment #2
bgilhome commentedComment #3
bgilhome commentedComment #4
wim leersThis is already fixed in HEAD and comes with test coverage, since #2576983: Add tests to ensure translated content works as expected :) The next release will ship with this!
Comment #5
wim leersI was a tad too fast, because the issue title doesn't match what the patch is doing!
Clarified title, now what is still needed is test coverage.
Great find! (And another clear reason we need more test coverage in this module.)
Comment #6
wim leersActually, this is working fine.
I understand this observation:
… it's because it's not
\Drupal\entity_embed\EntityEmbedBuilderthat does the loading of the translation, that's up to to the individual@EntityEmbedDisplayplugins.Attached is test coverage that passes against HEAD (at least locally).
Comment #7
wim leersComment #9
wim leers