Overview
When Canvas evaluates prop expressions that traverse entity references (e.g., a paragraph referencing a media entity, or an entity_reference field pointing to a taxonomy term), the referenced entities are
always returned in their default language — not the current page/content language. On multilingual sites, this means component props populated from referenced entities display untranslated content.
Steps to reproduce:
1. Enable content translation on a referenced entity type (e.g., Media, Taxonomy term)
2. Create a Canvas component with a prop sourced from a reference field (e.g., image → entity reference → media → file URI)
3. Create content in the default language, translate the referenced entity
4. View the page in the translated language
5. The referenced entity's field values appear in the default language, not the translated one
Root cause:
Evaluator::doEvaluate() follows DataReferenceInterface to load referenced entities but never calls getTranslation() on them. The referenced entity is used as-is from the reference property, which returns it
in the default/stored language.
Proposed resolution
- Add a resolveTranslation() helper that checks TranslatableInterface and calls getTranslation($language_code) when a translation exists
- Thread $language_code through the entire evaluate()/doEvaluate() recursion chain
- At the entry point (EntityFieldPropSource::evaluate()), seed $language_code from the host entity's language; fall back to current language via LanguageManager
- Apply resolveTranslation() at every point a referenced entity is resolved (3 locations in doEvaluate())
User interface changes
| Comment | File | Size | Author |
|---|---|---|---|
| canvas-translation-referenced-entities.patch | 9.57 KB | julien |
Issue fork canvas-3583379
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
penyaskitoThis is a duplicated report of #3552924: When rendering content templates' linked prop sources (entity fields, host entity URLs …), load the relevant translation instead of the default, which has an MR and reviews already.
Comment #6
wim leersActually, I think this would be helpful to land separately as I described in #3546597-36: [PP-1] Create Canvas pages in any enabled content language.
See #36.1 there, and my review on that MR.
🙏
Comment #7
wim leers@penyaskito in #4 is not wrong; that feedback should be incorporated here. What we really need:
Comment #8
omarlopesinoThanks for all the feedback and explanations in this issue and #3546597: [PP-1] Create Canvas pages in any enabled content language Wim, I got the full picture with it!
I think we could move the PHPunit tests from #3546597: [PP-1] Create Canvas pages in any enabled content language, which should be easily cherry-picked. And then take that as a base , and add tests about multilingual tests on static prop sources and entity field prop sources here, and apply all the feedback from #36.1. And probably keep the cypress tests on the other task, so they are dependent on accesing the entity with a different language.
I can dedicate time to it this weekend and come back to the MR !876 with tests for all use cases, and content templates testing, or at least a great advance.
Comment #9
omarlopesinoI have updated the tests to have more use cases and added the #slow tag because, otherwise, tests timeout would have been exceeded.
To continue with this, it is needed to add kernel tests for content templates and page regions.
Comment #11
hitchshockAdded new tests and fixed small pipeline issues
Comment #12
flyke commentedApparently since just now, MR!876 fails to apply to canvas 1.x-dev