For a project I used the i18n and entity_translation module in combination. Therefore I created a content type with i18n translation and one with entity_translation. On both I added the same paragraphs field and selected for the one with entity translation that it should be translatable. After adding some language neutral content to the content type with i18n translation, I wanted to switch the language of this content. When I did this, I recognized that the added paragraph items disappear.

Steps to reproduce:

  • Install a fresh drupal version
  • Install i18n (with i18n_node), entity_translation and paragraphs
  • Configure the site as multisite with at least 2 languages
  • Create a paragraphs bundle with a long text field
  • Configure the Basic page content type with multilingual support (Enabled, with translation) and add a paragraphs field to it
  • Configure the Article content type with multilingual support (Enabled, with field translation) and add the same paragraphs field as in the page content type to it and choose that this field supports Field translation
  • Create a language neutral Basic page with a paragraph with some text and save it
  • You will see the content with the paragraph
  • Edit the same content and change the language
  • You will see, that the paragraph element disappears

As a solution for this problem I thought that I just can use a new non translated field, but I also think that this is an unexpected problem and should be solved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

schwarli4783 created an issue. See original summary.

howdytom’s picture

yes, I am able to reproduce this as well. Did you find a workaround?

schwarli4783’s picture

Unfortunately not. The only solution for me at the moment is to create a new non translated field and use this field instead.

sonneworks’s picture

I noticed that in this file: paragraphs.field_formatter.inc the call to view() does not have a language set

if (entity_access('view', 'paragraphs_item', $paragraph)) {
            $element[$delta]['entity'] = $paragraph->view($view_mode);
          }

shouldn't this be

if (entity_access('view', 'paragraphs_item', $paragraph)) {
            $element[$delta]['entity'] = $paragraph->view($view_mode,$langcode); //if lang is null here it defaults to LANGUAGE_UNDEFINED
          }

that seems to solve it for me

howdytom’s picture

Status: Active » Needs review
ciss’s picture

Status: Needs review » Active

There's no patch to review.

sonneworks’s picture

sonneworks’s picture

Status: Active » Needs review
ciss’s picture

Status: Needs review » Needs work

@sonneworks please follow https://www.drupal.org/node/707484 to create a patch that can be applied and tested. I'm guessing the patch can't be applied by the testbot because the "diff --git ..." and "index ..." lines are missing.

ianwensink’s picture

Status: Needs work » Needs review
FileSize
675 bytes

Have the same problem. Took #7 and made it into an actual patch, so now it can be applied.

heliogabal’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2645646: Translated node reference in paragraph. $langcode not passed to view method.

there is actually another more complete patch available that does the same thing at this related issue:

https://www.drupal.org/project/paragraphs/issues/2645646

I think this should get closed as duplicate therefore. Feel free to reopen if the other patch doesn't resolve this issue as well - it will definitely solve it better than the patch within this issue.