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

Issue fork canvas-3583379

Command icon 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

julien created an issue. See original summary.

shubham.prakash made their first commit to this issue’s fork.

penyaskito’s picture

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

wim leers’s picture

Version: 1.3.2 » 1.x-dev
Category: Bug report » Feature request
Status: Closed (duplicate) » Needs work
Issue tags: +blocker
Related issues: +#3546597: [PP-1] Create Canvas pages in any enabled content language

Actually, 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.

🙏

wim leers’s picture

@penyaskito in #4 is not wrong; that feedback should be incorporated here. What we really need:

  1. assess all 3 MRs and combine them into the best possible way
  2. write maintainable test coverage for myriad use cases, which is what I outlined in that #36.1
omarlopesino’s picture

Thanks 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.

omarlopesino’s picture

I 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.

hitchshock made their first commit to this issue’s fork.

hitchshock’s picture

Status: Needs work » Needs review

Added new tests and fixed small pipeline issues

flyke’s picture

Status: Needs review » Needs work

Apparently since just now, MR!876 fails to apply to canvas 1.x-dev