Problem/Motivation

In order to enable translation, one can visit the admin UI to enable all translatable fields:
admin/config/regional/content-language

All fields added to the paragraph bundles currently don't show up.

Also when editing a paragraph
URL admin/structure/paragraphs_type/*
It is not possible to mark a paragraph type translatable.

Compared to content type settings for translatability:

Proposed resolution

Paragraphs need to support translation on entity level. This is really challenging.
In regular situations it is not the entity reference that should be set to translatable, since the wrapping field should maintain consistent references. Thus all translations of a certain content should maintain the same set of translated paragraphs.
When translating a content, all paragraphs from the default language should still be there and the user should have the ability to translate them into the target language.
On save, the paragraph entities should be updated with the proper language context to persist the translations.

Field collection struggled a lot with adding support.
Paragraph in D7 has no real translation support. When making the entity reference field translatable, translated paragraphs have absolutely no relationship under each other. This should be avoided as things fall apart for tools like TMGMT to maintain translation workflows.

Setting to major as this is a highly limiting situation with the current code.

Remaining tasks

User interface changes

API changes

CommentFileSizeAuthor
#41 paragraphs_2414913_41_translation.interdiff.txt1.15 KBmiro_dietiker
#41 paragraphs_2414913_41_translation.patch11.33 KBmiro_dietiker
#38 paragraphs_2414913_38_translation.interdiff.txt927 bytesmiro_dietiker
#38 paragraphs_2414913_38_translation.patch11.19 KBmiro_dietiker
#36 pp_1_support_entity-2414913-35-interdiff.txt1.58 KBsasanikolic
#36 pp_1_support_entity-2414913-35.patch10.98 KBsasanikolic
#34 pp_1_support_entity-2414913-34-interdiff.txt1.68 KBsasanikolic
#34 pp_1_support_entity-2414913-34.patch10.98 KBsasanikolic
#30 pragraphs_2414913_entity_30.interdiff.txt1.62 KBmiro_dietiker
#30 pragraphs_2414913_entity_30.patch10.24 KBmiro_dietiker
#28 support_entity-2414913-28-interdiff.txt2.22 KBsasanikolic
#28 support_entity-2414913-28.patch8.62 KBsasanikolic
#25 support_entity-2414913-25-interdiff.txt2.18 KBsasanikolic
#25 support_entity-2414913-25.patch8.61 KBsasanikolic
#24 support_entity-2414913-24-interdiff.txt1.74 KBsasanikolic
#24 support_entity-2414913-24.patch8.01 KBsasanikolic
#21 support_entity-2414913-21-interdiff.txt1.3 KBsasanikolic
#21 support_entity-2414913-21.patch7.95 KBsasanikolic
#17 support_entity-2414913-17.patch6.65 KBsasanikolic
#10 support_entity-2414913-10.patch7.36 KBAnushka-mp
#10 support_entity-2414913-10-interdiff.txt952 bytesAnushka-mp
#8 support_entity-2414913-8.patch7.55 KBAnushka-mp
Screen Shot 2015-01-27 at 11.15.15 .png43.47 KBmiro_dietiker
Screen Shot 2015-01-27 at 11.14.47 .png22.34 KBmiro_dietiker
Screen Shot 2015-01-27 at 11.09.49 .png25.74 KBmiro_dietiker

Comments

miro_dietiker’s picture

I added this to our team board. Not yet scheduled for immediate progress. :-)

miro_dietiker’s picture

Note: When implementing this, pay special attention to the delete (confirm, restore) workflows.

jeroen.b’s picture

Status: Active » Needs work
miro_dietiker’s picture

The more we are thinking about this, the more challenging this task seems.

See also this nice task at field collection module with almost 300 replies and work in progress for 3 years...
#1344672: Field Collection: Field translation (entity_translation) support.

jeroen.b’s picture

Shouldn't it be easier in D8 though?

miro_dietiker’s picture

As stated overthere, an own field type might simplify a bit...
#2430209: Create own fieldtype for Paragraphs

But also these tasks show a bit what complexity we touch:
#2429335: Deletion of referenced entities
#2428833: Unable to 'save and keep published' after editing content with paragraphs in testing
And we have the extra revision topic... #2426631: Add revision support using entity reference revision module

Multilingual is for many of these cases another dimension added in complexity.

I guess we will just try it and quickly learn from failing. ;-)

miro_dietiker’s picture

Status: Needs work » Active

Hint, paragraphs shows up on the list of translatable entity types. If i enable it though after save, the fields are not translateable and then when editing a second time, the checkbox is also reset.

Thoughts about our UX goal:
As a site builder i define some fields of my paragraph bundles as multilingual, with more than one language enabled. (BROKEN NOW)
As a translator, if i want to create a translation of a node with paragraphs, i
- have the node created, with language assigned
- click on translate tab from node detail
- click on Add for new translation language
- expect to have all paragraphs prefilled with original language

Now the problem is the composite relationship between the node and paragraph entities. As long as the reference relationship is not translatable, this relationship needs to be frozen when translating, meaning when translating, i
- can not remove/delete a paragraph
- can not add a paragraph
- can not switch type of a paragraph (upcoming feature)

Note that if the entity reference is translatable, the limitations above do not apply, but there are many other issues related with it. Thus we recommend to start with a clean implementation of the description above.

Anushka-mp’s picture

Status: Active » Needs review
StatusFileSize
new7.55 KB

As a first step we created tests for the basic workflow in translating paragraph entities.

paragraphs shows up on the list of translatable entity types. If i enable it though after save, the fields are not translateable and then when editing a second time, the checkbox is also reset.

The above problem happens due to #2449457: inconsistent checks in content_translation and also we found this #2450251: Bundle cache is not invalidated after changing translation settings.
As a temporary solution, a dummy canonical form and a route has been added in this patch (can be removed later after the core issues gets fixed.)

We need to extend tests and discuss more on how to improve the translation workflow and the user interface.

Uploading the patch with a quick fix and basic tests.

berdir’s picture

So the tests prove that the basics work, all we need to do is the get translation for the entity we're attached to. Which is pretty nice.

Questions/Next steps:

- For what we're doing, we don't actually need content_translation, but it provides a nice UI to manage translatability of fields
- The translation handler does some weird things to the labels, it adds (All languages) everywhere, but that's not actually correct, we need to look into why it is doing that and how we can prevent it.
- Per miros suggestion, we should hide/disable the buttons to remove/add additional paragraphs when editing a translation. check $paragraph_item->language()->getId() != $paragraph_item->getUntranslated()->language()->getId()
- Do we need to make the translation behavior configurable, if so, how?
- How should it behave if you make the paragraph field translatable? How do we explain to users that that is probably not what they want? Do we even want to support that (can we prevent it?)

And tests for each of those things, as we fix/decide them.

Also, screenshots :)

Anushka-mp’s picture

The dummy canonical form and routing removed. we'll have to wait for #2449457: inconsistent checks in content_translation to pass the tests.

Status: Needs review » Needs work

The last submitted patch, 10: support_entity-2414913-10.patch, failed testing.

cgalli’s picture

Followup:
- Make paragraphs_demo multilingual. Enable translation for paragraphed article type.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 10: support_entity-2414913-10.patch, failed testing.

miro_dietiker’s picture

The README should explain how to properly configure multilingual paragraphs.
And outline the limitations with reference to #2461695: Support asymmetric translations

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new6.65 KB

Rerolled...

Status: Needs review » Needs work

The last submitted patch, 17: support_entity-2414913-17.patch, failed testing.

miro_dietiker’s picture

Hm, there's a fail in the test run.

And see my comment from #16, we need the readme extended.. Or a separate documentation task.

We should push this in ASAP to make paragraph translation work.

berdir’s picture

This fails because #2449457: inconsistent checks in content_translation is not committet yet, we need to get that in first.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new7.95 KB
new1.3 KB

Added the description in the README file. Hope it's clear enough.

Status: Needs review » Needs work

The last submitted patch, 21: support_entity-2414913-21.patch, failed testing.

miro_dietiker’s picture

Some readme feedback. :-)

  1. +++ b/README.txt
    @@ -9,3 +9,29 @@ When you use the Entity Reference Paragraphs widget + Entity Reference selection
    + * Enable the Paragraph module and TMGMT module.
    ...
    + * Check Paragraphs as the embedded reference in Configuration » Translation Management settings.
    

    Paragraphs work without TMGMT. This module should not have any reference in the configuration to TMGMT at all.

  2. +++ b/README.txt
    @@ -9,3 +9,29 @@ When you use the Entity Reference Paragraphs widget + Entity Reference selection
    + * Enable Paragraphed article to be translatable in Configuration » Content language and translation:
    

    Paragraphed article is only an example content type from the demo module.

    Either you refer to the demo setup... Or you refer to any custom content type with a paragraph field.

  3. +++ b/README.txt
    @@ -9,3 +9,29 @@ When you use the Entity Reference Paragraphs widget + Entity Reference selection
    +	- Under Content check Paragraphed article
    

    Tab here...

  4. +++ b/README.txt
    @@ -9,3 +9,29 @@ When you use the Entity Reference Paragraphs widget + Entity Reference selection
    +   - The fields inside the Paragraph block should be set to translatable
    

    Better: Set the fields of each paragraph type to translatable as required.

  5. +++ b/README.txt
    @@ -9,3 +9,29 @@ When you use the Entity Reference Paragraphs widget + Entity Reference selection
    +For now, this module does not support switching entity reference revision field of the paragraph itself into multilingual mode. This would raise complexity significately.
    

    Wrong line break.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new8.01 KB
new1.74 KB
sasanikolic’s picture

Corrected word wrapping and changed untranslatable to NOT translatable. :)

The last submitted patch, 24: support_entity-2414913-24.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 25: support_entity-2414913-25.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new8.62 KB
new2.22 KB

Word wrapping to 80...

Status: Needs review » Needs work

The last submitted patch, 28: support_entity-2414913-28.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Needs review
StatusFileSize
new10.24 KB
new1.62 KB

Aww... Providing interdiff.
The paragraphs_demo module is first used in this test. It had implicit dependency to path and menu_ui module.. And paragraphs_demo shipped config through views config, but still with only default values. Dropped it.

Still depends to the core patch. :-)

Status: Needs review » Needs work

The last submitted patch, 30: pragraphs_2414913_entity_30.patch, failed testing.

miro_dietiker’s picture

Title: Support entity translation of paragraphs » [PP-1] Support entity translation of paragraphs
Status: Needs work » Postponed
Related issues: +#2449457: inconsistent checks in content_translation

OK, nice, ready to commit. formally marking it postponed, adding related.

miro_dietiker’s picture

Status: Postponed » Needs work

Aww... Strange side effects here...

  • when adding a translation, also the origin language is overwritten.
  • when editing a translation, also my wysiwyg fields get empty, although the previous value was stored and shown on display.
  • then editing again, the translation is empty. But when filled out again and saved, things work again regularly.

Let's start with adding a test that checks the first two buggy steps.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new10.98 KB
new1.68 KB

Reproduced the issues above in the test.

Will try to debug now.

Status: Needs review » Needs work

The last submitted patch, 34: pp_1_support_entity-2414913-34.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new10.98 KB
new1.58 KB

Better test.. :)

Status: Needs review » Needs work

The last submitted patch, 36: pp_1_support_entity-2414913-35.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Needs review
StatusFileSize
new11.19 KB
new927 bytes

This is needed to make the failing tests pass.

Status: Needs review » Needs work

The last submitted patch, 38: paragraphs_2414913_38_translation.patch, failed testing.

miro_dietiker’s picture

Status: Needs work » Postponed

Prfct!

miro_dietiker’s picture

Title: [PP-1] Support entity translation of paragraphs » Support entity translation of paragraphs
Status: Postponed » Needs review
StatusFileSize
new11.33 KB
new1.15 KB

Unpostponing this:
- commenting the UI checking lines. It still works.
- create followup to reenable: #2473721: Check multilingual settings for paragraphs

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

  • jeroen.b committed 882769f on 8.x-1.x authored by miro_dietiker
    Issue #2414913 by sasanikolic, miro_dietiker, Anushka-mp: Support entity...
jeroen.b’s picture

Awesome work, thanks everyone! Pushed to dev

berdir’s picture

Status: Reviewed & tested by the community » Fixed
miro_dietiker’s picture

Yay! Party! Welcome to the multilingual world! Thx for pushing! Me Xited! ;-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tom robert’s picture

I'm trying to find out why paragraphs items need to be defined on the translation page. Would it not make more sense that paragraphs inherits the multilingual settings from its hosts entity field?

If this can be accomplished with multiple fields from different bundles who use the same paragraph type. Not quite sure if drupal 8 can handle this.

tom robert’s picture

Status: Closed (fixed) » Active
berdir’s picture

Status: Active » Closed (fixed)

Please open a new support and explain what you want to do exactly.

henk’s picture

I had the same problem. Paragraph with image field, alt and title is translatable, but file path is not translatable.
Fatal error appears:


InvalidArgumentException: Invalid translation language (und) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 748 of /app/core/lib/Drupal/Core/Entity/ContentEntityBase.php)

Workorund for that problem is translate whole paragraph fields (admin/config/regional/content-language) or untranslate it like in #21 comment. Mixed mode have still problems.