Problem/Motivation

On a entity reference field, I cannot get the field content translation within a SDC component.

Steps to reproduce

1. Install Ui patterns field formatter and paragraphs, content translation
2. Create a custom SDC component (ex: card) with a title slot
3. Create a paragraph with content entity reference revision. Add this paragraph to content type.
4. Choose Component ui pattern in display mode and target the title of the content
5. Create misc contents in english and french (for example). In the contents try to link your custom paragraph to another entity.
6. Check in front: the referenced entity is not displayed in the good language.
7. If you reset display mode to default, the referenced entity is displayed properly

Is this a bug or I use the module not properly?

Sincerely,

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

alexander94 created an issue. See original summary.

christian.wiedemann’s picture

Assigned: Unassigned » christian.wiedemann
ipumpkin’s picture

This patch fix multilangage issue for: field formatter -> component -> entity field -> field property, you can have a try.

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

jjsanz changed the visibility of the branch 3562508-is-ui-patterns to hidden.

jjsanz’s picture

Thank you @ipumpkin for your initial patch, which addresses multilingual context propagation for field properties in SDC components.

Building on your work, I have made two main improvements:

Views compatibility:
Your patch worked well for regular entity displays, but it did not handle multilingual context correctly when components were rendered from Views. I have extended the logic so that the ui_patterns:lang_code context is reliably set and used when rendering SDC components from Views, ensuring the correct translation is used for each row.

Entity links translation:
I also added support for generating entity links in the correct language. Now, when a component outputs an entity link (e.g., node or paragraph link), it uses the translation matching the ui_patterns:lang_code context if available. This ensures links always point to the correct translation, both in regular displays and in Views.

How to test:

Create a multilingual site with translated content entities.
Use a UI Patterns SDC component that outputs entity fields and/or entity links, both in regular entity displays and in Views.
Switch between languages and verify that both field values and links are rendered in the correct language.
Let me know if you have any questions or need further adjustments!

jjsanz’s picture

Status: Active » Needs review
ipumpkin’s picture

Component: Tests » UI Patterns Field Formatters

Hi @jjsanz, thanks for your great improvement, fix test faliure

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

rtkr’s picture

Add merge request for version 2.0.19 as the problem still occurs for prop values.

just_like_good_vibes’s picture

Assigned: christian.wiedemann » just_like_good_vibes
Status: Needs review » Needs work

Thanks ipumpkin and jjsanz for your work and inputs.

The reported chain (formatter, component, referenced entity, property) is fixed by MR !545 in #3516063: No access check on Referenced entities: the referenced entity is translated where it is resolved, before the access check, so the FieldValueSourceBase and EntityLinksSource changes of !477 and !534 are not needed anymore.

What is left is the views row: ComponentRow gives the row entity as Views loaded it, so the default translation. It should give the translation of the view rendering language, like core RenderedEntity and EntityRow do with getEntityTranslationByRelationship(). I will push that in a new branch with a kernel test.