When a node in LANG3 is based on the node in LANG2 which is based on LANG1, paragraph fields behave differently depending on whether the paragraph field is added before, or after, the node is translated

Created on 14 April 2025, 10 days ago

Problem/Motivation

If a node in LANG3 depends on LANG2 which depends on LANG1, and the paragraph in LANG1 and LANG2 are different, and the paragraph in LANG3 is not set, one would expect the paragraph in LANG3 to show the value of the paragraph in LANG2, not the value in LANG1.

This is the case if one:

* creates the node in LANG1 with the paragraph
* translates the node to LANG2 and translates the paragraph
* translates the node to LANG3 and does not translate the paragraph

However, if one does:

* creates the node in LANG1 WITHOUT the paragraph
* translates the node to LANG2 and translates the paragraph
* translates the node to LANG3 and does not translate the paragraph
* now go to LANG1 and create the paragraph

In the above case, the paragraph in LANG3 will show the value from LANG1, not the value from LANG2.

Steps to reproduce

* Install Drupal 11.1.6
* drush si -y
* composer require drupal/paragraphs
* drush en -y content_translation paragraphs
* /admin/config/regional/language/add
* Add Afrikaans
* /admin/config/regional/language/add
* Add Catalan
* /admin/structure/paragraphs_type/add
* label: paragraph
* save and manage fields
* /admin/structure/paragraphs_type/pagragraph/fields/add-field
* label: paragraph_field
* choose an option: text plain
* continue
* save settings
* /admin/structure/types/manage/page/fields/add-field
* paragraphs
* continue
* label: paragraphs
* continue
* save settings
* /admin/config/regional/content-language
* select Paragraph
* in paragraph, select the paragraph type "paragraph"
* save configuration
* /admin/structure/types/manage/page
* language settings: enable translation
* save
* /node/add/page
* title: page
* paragraph_field: "paragraph en before translation"
* /af/node/1/translations/add/en/af
* paragraph_field: "paragraph af"
* save (all translations)
* /ca/node/1/translations/add/af/ca
* save (all translations)

We now have the following situation:

* node 1 in "ca" depends on node 1 in "af"
* node 1 in "af" depends on node 1 in "en"
* the paragraph field in English is "paragraph en before translation"
* the paragraph field in Afrikaans is "paragraph af"
* the paragraph field in Catalan is not set

Because node 1 in Catalan is based on Afrikaans, and you visit /ca/node/1, you will see the paragraph field in Afrikaans, "paragraph af".

If you visit /ca/node/2/edit, you will see "paragraph af" in "paragraph_field". This is because the paragraph field is not set in Catalan, and the system will show you the paragraph field in Afrikaans.

Next,

* /node/2/edit
* Add paragraph
* In the second paragraph, paragraph_field: "paragraph en before translation 2"
* save (all translations)
* /af/node/2/edit
* In the second paragraph, paragraph_field: "paragraph af 2"

Now, when you go to /ca/node/2/edit or /ca/node/2, you will see "paragraph en before translation 2", not "paragraph af 2".

Because the Catalan node is based on the Afrikaans node, it would make more sense to see "paragraph af 2", not "paragraph en before translation 2".

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada alberto56

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @alberto56
  • 🇨🇦Canada alberto56

    If anyone else needs this, I have created a module which can "fix" the language chain of paragraphs to match the language chain of their parents, for example:

    If node 1 has language x which is based on language y which is based on language z, this module provides a way to fix the paragraphs associated with this module so that they to, have language x which is based on language y which is based on language z.

Production build 0.71.5 2024