It’s me again. Here’s the situation:
I create a new node in English and add a text paragraph. After saving the node, I create a German translation and translate the paragraph content.
Later, in the frontend, I realize that I need an additional paragraph. So I use the Add function provided by Frontend Editing to create a new text paragraph in English.
When I then switch to German in the frontend to translate this newly added paragraph, and save it, the paragraph ends up having the same content in both languages. No separate translation is created, unlike the behavior in the backend.
The edit form from the paragraph_edit module handles exactly this case in its init() method. However, this method is never called in this frontend editing workflow.
The reason seems to be the line $form_state->set('entity_form_initialized', TRUE); in FrontendEditingFormBuilder::buildEditForm(). Since I don’t know why this was introduced, I have not provided a fix yet, but this logic should not be executed for paragraphs, as it prevents proper translation handling.
Issue fork frontend_editing-3570168
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:
- 3570168--paragraph-translation-language
changes, plain diff MR !162
Comments
Comment #2
a.dmitriiev commentedThank you @refs for finding this. Paragraphs translation is a very sensitive topic. Could you please give more details? What type of translation do you have: sync or async? I mean is your paragraph field marked as translatable or not? From what you described it seems that it is not, but just to confirm.
Comment #3
refsParagraph version is 1.20 on a current Drupal 10.6. We do not use any async stuff or other widgets. The paragraph fields are not translatable.
One questions about https://www.drupal.org/project/frontend_editing/issues/3560907. Unfortunately, I haven't had time to look at it yet, but I'll try to get to it next week. I'm only asking because it's now closed (fixed) but not merged, if I understand correctly.
Comment #4
a.dmitriiev commentedThe code from https://www.drupal.org/project/frontend_editing/issues/3560907 should be included in 2.0.0-beta10 and it was also backported to 1.9.0.
And here is the MR: https://git.drupalcode.org/project/frontend_editing/-/merge_requests/149 . It is shown as Merged.
Comment #7
stborchertWe had this problem also. When creating a paragraph in a content translation the paragraph gets the default language instead of the current language.
The changes introduced in MR !162 fixes this for us.
Comment #8
a.dmitriiev commentedThank you @stborchert for moving this issue further. Please check my questions in the MR, I have some concerns about the changes that were done
Comment #9
stborchertComment #10
stborchertI've updated MR!162 to fix a small error in FieldReferenceHelper.
Comment #11
a.dmitriiev commentedHi @stborchert,
Unfortunately the changes from your MR are not fixing the reported issue for me. When the paragraph is created in default language with Frontend Editing and then I try to edit the translation, it still edits the source entity.
I have tried to check myself and I tried a bit different approach, see MR here https://git.drupalcode.org/project/frontend_editing/-/merge_requests/165... . I tried to use content_translation module as much as possible.
Comment #12
a.dmitriiev commentedComment #13
stborchertI had a quick look onto it and it looks much cleaner than our approach.
Will try to test this ... thanks!
Comment #14
hanan alasariComment #15
hanan alasariTest setup
- Host content is translatable
- Paragraphs reference field is not translatable
- A new paragraph is added through Frontend Editing on the default language version
Steps to reproduce
1. Create content in the default language with a paragraph.
2. Add a translation for the content.
3. Return to the default language frontend page.
4. Add a new paragraph using Frontend Editing.
5. Open the translated version.
6. Edit/translate the newly added paragraph.
Before the fix
Editing the newly added paragraph in the translated version also affected the source/default language content.
After the fix
The newly added paragraph keeps separate values per language as expected, and editing the translation no longer affects the source entity.
Result
RTBC from my side.
Comment #16
hanan alasariComment #17
hanan alasariComment #18
stborchert@hanan-alasari Which MR did you test? Did you see comment #11?
Comment #19
hanan alasarithat’s the one — I tested MR !165. and after applying the fix branch the translation worked correctly.
https://git.drupalcode.org/project/frontend_editing/-/merge_requests/165...
Comment #22
a.dmitriiev commented