Problem/Motivation
There is no way to translate panelizer of an entity.
Steps to test
1 - create a content type
2 - make it panelized and multilingual
3 - create a content of that type
4 - translate the content
5 - go the node view and use the in-place editor to insert any block into the layout
6 - save the layout as "custom layout"
7 - refresh the page
8 - the block is not here
On the original version of the node, step 8 works.
Also the changes from step 8 is applied to original language's node. There is no way to change the content of translation once the main node translated.
Proposed resolution
Allow a way to provide language support on panelizer. This can be done by providing a way to managed translation of ->panelizer field of entities.
Remaining tasks
1. Write tests to prove the patch doesn't break any existing functionality
2. Review initial patch in #6 to confirm the approach.
User interface changes
Provides a way to manage different content, layout(?) per language for an entity.
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | 2778565-48.patch | 10.15 KB | rafmagsou |
| #47 | 2778565-47.patch | 12.41 KB | phenaproxima |
| #46 | 2778565-46.patch | 10.51 KB | phenaproxima |
| #38 | panelizer-multilingual-2778565-38.patch | 10.54 KB | bendeguz.csirmaz |
| #25 | interdiff.txt | 1.15 KB | eyilmaz |
Comments
Comment #2
nishruu commentedComment #3
nishruu commentedComment #4
eagle-m commentedI have the same issue as Nishruu / Does any one have any solutions for this please?
Comment #5
vijaycs85By the look of it, we don't have this feature in D7 either and progressed on #2070891: Support core Content Translation by cloning the Panelizer display for the new entity for D7.
Comment #6
vijaycs85Initial patch that works....
Comment #7
damienmckenna@vijaycs85: Thanks for working on that!
We'll definitely need to add tests to make sure that both language-generic and language-specific functionality works correctly.
Comment #8
vijaycs85thanks for the quick review @DamienMcKenna. It wasn't very clear initially for me whether it's a missing functionality or a bug that needs a fix. Since it's missing functionality, updating issue metadata accordingly.
Comment #9
nishruu commentedThanks for working on the issue / feature @vijaycs85. However, I see no change after applying your patch. Any content added to the translated panelized node is instead added to the original one.
Comment #10
vijaycs85@Nishruu yeah. We need a patch for panels module as well. I have created and provided the patch there #2850782: Multilingual support for Panels IPE. Could you apply both patches and see if it works. I also should inform that current patch (in #6) only fixes the save() operation ('save custom' link). I am working on load other operations.
You can verify/test this patch by:
1. Creating a node and add all the items and translate the node.
2. In translated node, remove few items from the node (by clicking edit link in IPE tray and remove elements using "x" next to them)
3. Click save and then click 'Save as custom'
If you load node on both original and translated version of node, you can see your changes on translated node. Without this patch, the changes always affects default language.
Comment #11
vijaycs85More updates on adding new components to translated pages.
Comment #13
vijaycs85ok, I will check the test fails.
@Nishruu: you need the patch in #11 for loading and saving panelizer data per language. However it doesn't work for draft mode i.e. if you make any change to any block in one language, the same content get displayed on other languages as well until save changes. This is because of tempstorage id is per node. We can use hook_panels_ipe_tempstore_id_alter() to make the id language aware. Here is what I have:
Comment #14
nishruu commentedThe combination of patches #11 + #2850782: Multilingual support for Panels IPE seems to work, thank you.
Is hook_panels_ipe_tempstore_id_alter an actual hook in panels_ipe ? I don't see it in the code.
Comment #15
vijaycs85@Nishruu, thanks for confirming it.
hook_panels_ipe_tempstore_id_altershould be added in one of your custom module. You can learn more about creating custom module here.Comment #16
nishruu commentedI have plenty of experience creating custom module for D7, but it's my first D8 site.
However, if hooks are still the same as in D7, hook_panels_ipe_tempstore_id_alter should be triggered by the panels_ipe module, for example in panel_ipe.api.php, so that a custom module can work with the hook.
Comment #17
damienmckennaA hook is still implemented in the same way, thankfully ;-)
Comment #18
ckaotikWhen using the patch in #11, we've encountered whitepages when trying to load panelized nodes in languages for which no translation exists. We've worked around this by adding a check using
$entity->hasTranslation($langcode)before trying to get the translation inPanelizerFieldPanelsStorage::loadEntity:Also, @Nishruu was just wondering where the alter hook is actually triggered (not how or where to implement it).
hook_panels_ipe_tempstore_id_alteris not clearly documented, and I couldn't find any info on it either.Comment #19
japerryRegarding comment #14, this patch is required to change the tempstore: #2793801: Allow modules to influence the IPE tempstore ID
Comment #20
profak commented@ckaotik,
alter hook is being triggered within TempStoreTrait: https://www.drupal.org/files/issues/2793801-13.patch
You can implement like mentioned above:
Where id is Panels temp store id and $panels_display object.
Comment #21
damienmckennaWorking on some tests to clarify the language handling.
Comment #22
damienmckennaOne idea to expand the tests would be to see what happens if you try loading eg. 'fr/node/$nid' before that translation is available.
Comment #23
eyilmazUpdating patch from #11 with the comment from #8.
Comment #25
eyilmazAdd also check in Panelizer.php before trying to get the translation.
Comment #26
suldan commentedAny progress on this issue? Right now IPE isn't usable for multilingual sites.
Comment #27
sylus commentedI was initially very confused about this issue as I was migrating into panelizer displays just fine:
https://github.com/open-data/od/blob/8.x-2.x/modules/custom/od_ext/od_ex...
Didn't realize that since I was directly mapping to the field it wasn't a problem but reproduced this through the UI.
The latest patch does work for me though and resolved my issue. Were failed tests unrelated at that point in time?
Really appreciate the amazing work done here!
Comment #28
samuel.mortensonWhy would Panelizer be responsible for adding/removing translations? Does this address a use case where Panels IPE is used when viewing a path like /fr/node/1 where Node 1 does not have a French translation yet? If so, why is the "removeTranslation" call necessary?
Comment #29
eyilmazYou are right @samuel.mortenson. That Part of the Patch is really confusing and does not seem to make sense..
Comment #30
suldan commentedI applied the patch #25 manualy, and it solved the problem.
Comment #31
tipit commentedTested patch #25 and it seems to do the job. I mean the content is there but it is still not translatable.
But after adding content from IPE to a node I can no longer use "Revert to Default" so the changes are kind of permanent. Work around is of course remove individual contents one by one but the node stays in a changed state.
Comment #32
vegantriathleteComment #33
vegantriathleteNote: The patch in #11 caused the error noted in the related issue. It seems this has been pointed out in #18.
Comment #34
vegantriathleteI applied the updated patch and the server (WSOD) errors no longer occur.
Comment #35
bendeguz.csirmaz commentedThis patch:
1. I was not sure why adding/removing translations in Panelizer.php was needed, so I removed that part.
2. Fixes the "Revert to Default" button.
3. Adds a functional test.
Comment #36
phenaproximaComment #38
bendeguz.csirmaz commentedFixed the test of #35 and PanelizerFieldPanelsStorageTest.php.
Comment #39
phenaproximaComment #41
bendeguz.csirmaz commentedComment #42
damienmckennaThis looks good, thank you.
Would someone please be able to test it out? Thanks.
Comment #43
bendeguz.csirmaz commentedThere's still one bug I noticed.
When changing the layout without saving, it's not working.
You have to click the save button.
Comment #45
phenaproximaDoes anyone use this patch? I'm trying to figure out if the migration path to Layout Builder needs to support this functionality; frankly, I'm not sure how it would, since the multilingual support seems pretty incomplete (for example, changing the layout -- i.e., regions -- in use will change it for all translations, not just the one on which the change was made). But I'd like to hear if people are using this, so I can figure out what if anything needs doing.
Comment #46
phenaproximaConverted EditTranslatedContentTest to WebDriverTestBase.
Comment #47
phenaproximaRerolled to apply to both 8.x-4.x and 8.x-5.x.
Comment #49
Ralf Eisler commentedI have trouble updating a Lightning project from 8.7.6 Drupal to 8.8.5.
Strangely enough this worked two weeks ago on the same project and on a almost identically configured webserver.
I tried PHP 7.1, 7,2 and 7.3.
Comment #50
damienmckenna@Thomas Factory: Update your composer.json to use the latest patch, I just confirmed that one applies.
Comment #51
rafmagsou commentedSome code modifications
Comment #52
rafmagsou commented