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,
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | ui_patterns-multilanguge_process_for_field_property.patch | 628 bytes | ipumpkin |
Issue fork ui_patterns-3562508
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 #2
christian.wiedemann commentedComment #3
ipumpkinThis patch fix multilangage issue for: field formatter -> component -> entity field -> field property, you can have a try.
Comment #6
jjsanzThank 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!
Comment #8
jjsanzComment #9
ipumpkinHi @jjsanz, thanks for your great improvement, fix test faliure
Comment #12
rtkr commentedAdd merge request for version 2.0.19 as the problem still occurs for prop values.
Comment #13
just_like_good_vibesThanks 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
FieldValueSourceBaseandEntityLinksSourcechanges of !477 and !534 are not needed anymore.What is left is the views row:
ComponentRowgives the row entity as Views loaded it, so the default translation. It should give the translation of the view rendering language, like coreRenderedEntityandEntityRowdo withgetEntityTranslationByRelationship(). I will push that in a new branch with a kernel test.