Problem/Motivation
I have content type with paragraph reference field.
I can create node with en-int original language and de translation
Then if I want to create de-DE translation based on de, I can select translation source language on translation edit form. In such case new translation will be based on selected language, but paragraph translations are based on original language.
Steps to reproduce
- Create translatable paragraph type
- Create translatable content type with paragraph reference field
- Enable content moderation for the content type
- Enable 3 languages
- Create node with default language 1
- Add translation to language 2 and translate paragraphs too
- Add translation to language 3 based on language 2
- Check if default values of paragraph widget based on language 1 translation
Proposed resolution
In entity_reference_revisions_entity_revision_create we can check if entity has content_translation_source field and try to load source language translation of the target entity to use as source for new translation
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3295973-5.patch | 1.82 KB | kala4ek |
Issue fork entity_reference_revisions-3295973
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
vladimir.krupin commentedthere is a patch
Comment #4
kala4ekUpdated patch to be applicable for 1.11 version.
Comment #5
kala4ekUpdated patch that works with nested paragraphs too.
Comment #6
nikolay shapovalov commentedThanks for your patches, but please use MR approach instead of patch.
You can update existing MR #12, or create new one.
And it would be great if you can provide functional test to cover this issue.
Comment #8
nikolay shapovalov commentedI tried to replicate this issue, and I wasn't able.
Drupal 11 latest, paragraphs latest.
On step 6, I have dropdown "Source language: language 1" and I can change source from language 1 (default value) to language 2.
Then values from language 2 translation used.
Can you please provide more information?
Did you mark field node->paragraph translatable?
I found at documentation page:
And test Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsTranslationTest::testParagraphTranslation() covers similar logic.
Comment #10
refsUnfortunately, I don't currently have a Drupal 11 system to test it on, but I have installed various Drupal 10.5 systems with the latest Paragraphs (1.19), entity_reference_revisions 1.12 and the patch from #4 to fix this issue.
Now a customer has pointed out to me that it doesn't work with nested paragraphs. Patch #5 doesn't work with multiple nested paragraphs. For this reason, I have adapted the patch so that the parent that has also set a content source is now taken into account. As a rule, this should probably be the root/node.
Let's assume I have languages A, B, and C in the system. I create a node with a text paragraph in language A. I translate the node and its content into language B. So far, everything is correct. Now I want to translate the node into language C. Language A is selected as the source language by default, as it is the default language of the node, and everything is fine in the initial form. However, if I switch to language B as the content source, the content of the paragraphs continues to be output in language A. The problem exists both at the first level of paragraphs and at the nested level.
My paragraph fields are not translatable
I believe that the test only checks the language of the paragraph in the edit form step and not the initial content. The language of the paragraphs is always the language of the newly created translation and is correct.
Comment #11
refsComment #13
marcusml commentedWe just experienced the same issue on our site.
I was not able to reproduce it without content moderation enabled on the host entity. Maybe that was the case for @nikolay shapovalov in #18?
I've rebased the current branch and pushed a new approach where instead of crawling up the host entity we set the
content_translation_sourceon the composite entities instead, and create translations based on that.Added test for this as well.
Comment #14
marcusml commentedTaking a look at the test failures.
Comment #15
marcusml commentedI see the test failure was unrelated and on the main branch as well.
I've run the test-only job which expectedly fails. The result is available here: https://git.drupalcode.org/issue/entity_reference_revisions-3295973/-/pi...
Comment #16
berdirReviewed.
Comment #17
marcusml commentedThanks for the review. 🙏
I've addresses the feedback and it's now back for review again.
Comment #18
berdirThis conflicts and needs to be rebased.
Comment #19
marcusml commentedI've rebased on top of 8.x-1.x. Some jobs are failing but looks to be present on main branch as well. Back to review.
Comment #20
berdirThanks for sticking with this, merged.