Problem/Motivation

Related to #2946333: Allow synced Layout override Translations: translating labels and inline blocks
But this would be for defaults.

Proposed resolution

Remaining tasks

Basic implementation
Define where to set what's the default language of the layout? (like in views)
Check why URL is not accessible (403) in some cases (#64)
Hide "Translate layout" link if translation is disabled
Implement tests
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

IMPORTANT:

The MR requires MR!1505 from #2946333: Allow synced Layout override Translations: translating labels and inline blocks! (https://git.drupalcode.org/project/drupal/-/merge_requests/1505#note_59580)
You have to use both combined to make it work!

CommentFileSizeAuthor
#88 3044993-88.patch32.23 KBrodrigoaguilera
#87 3044993-87.patch8.28 KBrodrigoaguilera
#85 3044993-85.patch32.16 KBl_vandamme
#84 3044993-84.patch31.9 KBl_vandamme
#79 3044993-79.patch32.4 KBpjonckiere
#75 3044993-d10-75.patch40.51 KBhitchshock
#72 3044993-d10-72.patch40.53 KBnginex
#66 allow-synced-default-lb-translations.3044993.66.patch40.05 KBmatthijs
#65 allow-synced-default-lb-translations.3044993.65.patch39.97 KBmatthijs
#57 allow-synced-default-lb-translations.3044993.57.patch16.23 KBmatthijs
#52 allow-synced-default-lb-translations.3044993.48-52.interdiff.txt1.41 KBnginex
#52 allow-synced-default-lb-translations.3044993.52.patch39.75 KBnginex
#49 LayoutBuilderTranslationLinkFix.patch1008 bytesDonAtt
#48 allow-synced-default-lb-translations.3044993.48.patch39.12 KBgrayle
#48 allow-synced-default-lb-translations.3044993.47-48.interdiff.txt632 bytesgrayle
#47 allow-synced-default-lb-translations.3044993.47.patch38.72 KBgrayle
#47 allow-synced-default-lb-translations.3044993.45-47.interdiff.txt3.21 KBgrayle
#45 allow-synced-default-lb-translations.3044993.45.patch36.96 KBgrayle
#45 allow-synced-default-lb-translations.3044993.45-updated.patch39.53 KBgrayle
#45 allow-synced-default-lb-translations.3044993.45-to-updated-45.interdiff.txt2.91 KBgrayle
#43 interdiff_41_43.txt3.92 KBanmolgoyal74
#43 3044993_43.patch165.46 KBanmolgoyal74
#41 interdiff_39-41.txt577 bytesvsujeetkumar
#41 3044993_41.patch163.75 KBvsujeetkumar
#39 3044993-39.patch163.75 KBNitinLama
#39 interdiff_35_39.txt712 bytesNitinLama
#35 3044993-35.patch163.81 KBheddn
#35 interdiff_34-35.txt7.75 KBheddn
#34 3044993-34.patch163.49 KBanmolgoyal74
#30 3044993-30_plus_2946333-202.patch163.78 KBgrayle
#29 interdiff_19_29.txt535 bytesgrayle
#29 3044993-12_plus_2946333-164-rerolled89x-29.patch163.23 KBgrayle
#25 interdiff_21-25.txt4.89 KBrajandro
#25 3044993-25.patch160.84 KBrajandro
#24 3044993-24.patch161.03 KBrajandro
#21 3044993-21.patch161.18 KBrajandro
#19 interdiff_18_19.txt830 bytesgrayle
#19 3044993-12_plus_2946333-164-rerolled89x-19.patch163.38 KBgrayle
#18 interdiff_16_18.txt4.09 KBgrayle
#18 3044993-12_plus_2946333-164-rerolled89x-18.patch163.3 KBgrayle
#16 3044993-12_plus_2946333-164-rerolled89x.patch160.87 KBgrayle
#12 3044993-12_plus_2946333-164.patch161.54 KBtedbow
#12 3044993-12-do-not-test.patch37.4 KBtedbow
#10 interdiff-8-10.txt13.36 KBtedbow
#10 3044993-10_plus_2946333-157.patch156.21 KBtedbow
#10 2946333-10-do-not-test.patch39.31 KBtedbow
#8 3044993-8_plus_2946333-157.patch147.49 KBtedbow
#8 3044993-8-do-not-test.patch27.55 KBtedbow
#8 interdiff-7-8.txt8.34 KBtedbow
#7 3044993-7_plus_2946333-157.patch145.61 KBtedbow
#7 interdiff-5-7.txt14.71 KBtedbow
#7 3044993-7-do-not-test.patch26.67 KBtedbow
#5 3044993-5_plus_2946333-157.patch144.42 KBtedbow
#5 3044993-5-do-not-test.patch25.48 KBtedbow
#5 interdiff-3-5.txt2.68 KBtedbow
#3 interdiff-2-3.txt15.99 KBtedbow
#3 3044993-3-plus_2946333-155.patch141.9 KBtedbow
#3 3044993-3-do-not-test.patch39.78 KBtedbow
#2 3044993-2a-do-not-test.patch21.34 KBtedbow
#2 3044993-2-plus_2946333-153.patch138.39 KBtedbow

Issue fork drupal-3044993

Command icon 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:

Comments

tedbow created an issue. See original summary.

tedbow’s picture

Assigned: Unassigned » tedbow
Status: Active » Needs review
StatusFileSize
new138.39 KB
new21.34 KB

Here is the first in process patch. Patch includes #2946333-153: Allow synced Layout override Translations: translating labels and inline blocks but I also uploaded a do-not-test patch with just the changes for defaults. I had to make 1 change that affects both which I will update #2946333 with after this.

I had very limited experience with config_translation's APIs before so any help/feedback on that would be great

this patch

  1. creates \Drupal\layout_builder\ConfigTranslation\EntityViewDisplayMapper. This should probably be renamed because it only handles the layout builder settings. This should be able to co-exist with #2546212: Entity view/form mode formatter/widget settings have no translation UI. Right now there is no tab generate so you have to go to the page direclty, /translate from dispaly(as test does)
  2. Right now you can click "add" for new translation and the layout builder will show up with the correct contextual "Translate block" link but nothing else works
tedbow’s picture

Assigned: tedbow » Unassigned
StatusFileSize
new39.78 KB
new141.9 KB
new15.99 KB
  1. Adds test group to fix fail
  2. Removes bundle and view mode from layout_builder_config_translation_info and instead gets from the route because these are dynamic
  3. ComponentPluginTranslate now gets section storage from route parameter when in preview. See explanation #2946333-155: Allow synced Layout override Translations: translating labels and inline blocks where I also added this change
  4. Started work on actually saving in language override, currently not working
  5. Some nits

Status: Needs review » Needs work

The last submitted patch, 3: 3044993-3-plus_2946333-155.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB
new25.48 KB
new144.42 KB
  1. +++ b/core/modules/layout_builder/layout_builder.module
    @@ -428,3 +429,33 @@ function layout_builder_block_alter(&$definitions) {
    +  $entity_manager = \Drupal::entityManager();
    

    This is deprecated and not used here.

  2. +++ b/core/modules/layout_builder/layout_builder.module
    @@ -428,3 +429,33 @@ function layout_builder_block_alter(&$definitions) {
    +          'base_route_name' => "entity.entity_view_display.$entity_type_id.view_mode",
    

    This will fail in tests where 'field_ui_base_route' is not set for the entity type.

    I first tried making sure the base route exists but looking at config_translation_config_translation_info() it doesn't do this. I wondered why and found #2230091: Route rebuilding is not guaranteed to finish in time for the next request where checking if the route exists actually was removed. So I am following that pattern.

Status: Needs review » Needs work

The last submitted patch, 5: 3044993-5_plus_2946333-157.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new26.67 KB
new14.71 KB
new145.61 KB

#5 was random failure in a media test.

  1. Fixed the \Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::getTranslationOverride() so it loads and therefore saves the correct configuration
  2. Renamed the mapper to LayoutEntityDisplayMapper because this doesn't affect on all parts of the config entity
  3. Implement \Drupal\layout_builder\ConfigTranslation\LayoutEntityDisplayMapper::getEditRoute() so the edit form works now
  4. Added test coverage or editing and deleting the config translation.
  5. A bunch of coding standards
tedbow’s picture

StatusFileSize
new8.34 KB
new27.55 KB
new147.49 KB
  1. +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
    @@ -432,4 +449,98 @@ public function isApplicable(RefinableCacheableDependencyInterface $cacheability
    +        $this->translationOverride->set("third_party_settings.layout_builder.sections.$delta.components.$uuid", $configuration);
    

    The key for set here needs a ".configuration" on the end.

  2. +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
    @@ -432,4 +449,98 @@ public function isApplicable(RefinableCacheableDependencyInterface $cacheability
    +        if (isset($section['components'][$uuid])) {
    +          return $section['components'][$uuid];
    

    Needs to use 'configuration'

  3. fixed these 2 and the configuration is actually used 🎉. Added a test for this with and without a translated node.

Status: Needs review » Needs work

The last submitted patch, 8: 3044993-8_plus_2946333-157.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new39.31 KB
new156.21 KB
new13.36 KB
  1. #8
    +++ b/core/modules/layout_builder/layout_builder.module
    @@ -438,7 +437,7 @@ function layout_builder_config_translation_info(&$info) {
    -    foreach (EntityViewDisplay::loadMultiple() as $entity_view_display) {
    +    foreach (LayoutBuilderEntityViewDisplay::loadMultiple() as $entity_view_display) {
    

    This caused the kernel test to fail in #8

  2. Added \Drupal\layout_builder\ConfigTranslation\LayoutEntityDisplayUpdater::presaveUpdateOverrides() which updates the override component configuration for any components that have moved to a new section. This needs because \Drupal\language\Config\LanguageConfigFactoryOverride::onConfigSave would filter out any override configuration that doesn't match the new nesting structure of the component under the new section.

    Also the configuration would not load correctly.

    Right now I am doing this in layout_builder_entity_view_display_presave hook. I first had it in layout_builder_entity_view_display_update but this too late because \Drupal\language\Config\LanguageConfigFactoryOverride::onConfigSave would have already run.

    Another option would be too just do an event subscriber that listens for onConfigSave but at that point we only have config array and not the config entity. I also don't think we would the original data so it would be harder to just update the components that moved to a new section.

  3. +++ b/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php
    @@ -432,4 +449,98 @@ public function isApplicable(RefinableCacheableDependencyInterface $cacheability
    +  public function setTranslatedComponentConfiguration($uuid, array $configuration) {
    +    foreach ($this->getSections() as $delta => $section) {
    +      if ($section->getComponent($uuid)) {
    +        $this->translationOverride->set("third_party_settings.layout_builder.sections.$delta.components.$uuid.configuration", $configuration);
    +      }
    +    }
    

    This sets the configuration but doesn't check if the component was previously in a different section. I added this.

Status: Needs review » Needs work

The last submitted patch, 10: 3044993-10_plus_2946333-157.patch, failed testing. View results

tedbow’s picture

Status: Needs work » Needs review
StatusFileSize
new37.4 KB
new161.54 KB

This brings up to #2946333-164: Allow synced Layout override Translations: translating labels and inline blocks #164

There are some other fixes in here which should fix other tests

Status: Needs review » Needs work

The last submitted patch, 12: 3044993-12_plus_2946333-164.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

grayle’s picture

StatusFileSize
new160.87 KB

I rerolled it against 8.9, but I either messed up or I'm not seeing how this patch allows you to translate default layout builder config.

grayle’s picture

Alright, think something went wrong adding the patch to a running site (ran updb and it didn't fail), but reinstalling from scratch it works fine.

Now to see if I can add a button and the "don't show content preview" option.

grayle’s picture

Ok, translate button added and content preview toggle as well.

Also seems I uploaded a busted version of the patch before, so fixed that too. Changes are in interdiff.

grayle’s picture

Added config_translation module check

rajandro’s picture

Assigned: Unassigned » rajandro
Issue tags: +Needs reroll

Working on it.

rajandro’s picture

Assigned: rajandro » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new161.18 KB

Rerolled most of the functionality of this long patch and adding here. Needs to work on it to make it completely reroll for 9.1.x. However, I think we can break the functionality if possible so that it can be helpful to review and do any changes for this functionality.

Thanks
Rajandro

rajandro’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
rajandro’s picture

Assigned: Unassigned » rajandro
rajandro’s picture

StatusFileSize
new161.03 KB

Fixed the #21 error

rajandro’s picture

Assigned: rajandro » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new160.84 KB
new4.89 KB

FIxed phpcs violation of #24, adding interdiff from #21 to #25

PS: Four depreciation message needs to address lie as mentioned below:
+ @trigger_error('The entity_type.manager service must be passed to \Drupal\layout_builder\Element\LayoutBuilder::__construct(). It was added in Drupal 8.8.0 and will be required before Drupal 9.0.0.', E_USER_DEPRECATED);
+ @trigger_error('The plugin.manager.block service must be passed to \Drupal\layout_builder\InlineBlockEntityOperations::__construct(). It was added in Drupal 8.7.0 and will be required before Drupal 9.0.0.', E_USER_DEPRECATED);

Thanks

tedbow’s picture

@Grayle and @rajandro thanks for the reroll efforts.

re #21

Rerolled most of the functionality of this long patch and adding here.

I am sure what you mean. Which patch were you working off for the reroll?

Almost always we don't do a partial reroll unless there a specific, state reason to not include a part of the original patch. With a partial reroll if we want the original functionality we still have to go back to the original patch to figure out what is missing.

It looks like your patch was nearly the same size so maybe you do include all of it?

rajandro’s picture

@Ted, Thank you.

re #26

Which patch were you working off for the reroll?

I have taken "3044993-12_plus_2946333-164-rerolled89x-19.patch" as a reference to reroll.

Thanks
Rajandro

grayle’s picture

And 3044993-12_plus_2946333-164-rerolled89x-19.patch is a full reroll, done using the proposed methods here: https://www.drupal.org/patch/reroll

Only hiccup was setContext method for DefaultsSectionStorage, which was added to core since the #12 patch, but I merged those (can be seen here: https://www.drupal.org/files/issues/2020-06-22/interdiff_16_18.txt). Didn't want to take any chances, so parent:: call is in between the two bits of code to match both sources.

grayle’s picture

Ok, seems there was a duplicate declaration of a property in the tests. Fixed that, again for 8.9.x. Sorry I'm not rerolling against 9.1 dev but we're still a ways off from moving to D9 and we need translations for LB now.

grayle’s picture

StatusFileSize
new163.78 KB

Reroll based on patch 202 in the other issue and this issue's 12 patch.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

dravenk’s picture

Issue tags: +Needs reroll
anmolgoyal74’s picture

Assigned: Unassigned » anmolgoyal74
anmolgoyal74’s picture

Assigned: anmolgoyal74 » Unassigned
StatusFileSize
new163.49 KB

Re-rolled #30.

heddn’s picture

StatusFileSize
new7.75 KB
new163.81 KB

Hopefully fixes up some PHPCS and test failures

heddn’s picture

This could really use someone figuring out what parts of this patch are duplicated in #2946333: Allow synced Layout override Translations: translating labels and inline blocks and creating a 2nd patch that builds upon that work. The last time we had that split-up was back in #12. But I can't tell what since then is new or just attempts at fixing things up in a re-roll.

Leaving the re-roll tag on here, but only because we need to figure out what has changed in this issue since #12 and build a (hopefully) smaller patch that builds on top of the other.

heddn’s picture

Status: Needs review » Needs work

NW for a re-roll.

vsujeetkumar’s picture

@heddn I have checked after #12 there are no magor changes as per my understanding, few rerolls and PHPCS fixes are there, I am trying to understand, but no clue found, can you please help me out in this how to reroll this.

NitinLama’s picture

Assigned: Unassigned » NitinLama
StatusFileSize
new712 bytes
new163.75 KB

@here removing unused use statement.

NitinLama’s picture

Assigned: NitinLama » Unassigned
vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new163.75 KB
new577 bytes

Fixing CSPell issue.

Status: Needs review » Needs work

The last submitted patch, 41: 3044993_41.patch, failed testing. View results

anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new165.46 KB
new3.92 KB

Fixed failing test cases.

Status: Needs review » Needs work

The last submitted patch, 43: 3044993_43.patch, failed testing. View results

grayle’s picture

Here's #12 rerolled on top of the latest patch in the override issue, but not combined, so as a separate patch you can apply after applying the other issue's patch.

And then there's #12 + some minor updates in the same formfactor.

Hope this helps clear things up.

grayle’s picture

Forgot some pluses, added test changes from last rerolled patch.

grayle’s picture

DonAtt’s picture

StatusFileSize
new1008 bytes

Testing with Drupal 9.1.4. Installed both override issue #224 and this issue #48.
Generally works good, I could translate labels and they display correctly.

However, the "Translate layout" link URL is not always good.

First issue:
My installation uses a subdirectory in the path: http://localhost:8080/web/en/admin/bat/type-bundle/venue/edit/display/teaser
The prefix is duplicated: http://localhost:8080/web/web/en/admin/bat/type-bundle/venue/edit/display/teaser/translate

Second issue:
The default layout URL doesn't contain "/default" at the end: http://localhost:8080/web/en/admin/bat/type-bundle/venue/edit/display
So the translation link also misses that route param: http://localhost:8080/web/web/en/admin/bat/type-bundle/venue/edit/displa...
Should be: http://localhost:8080/web/en/admin/bat/type-bundle/venue/edit/display/default/translate

The problem is here, using the current URL as a base is not reliable:

+    $form['translate_layout'] = [
+      '#type' => 'link',
+      '#title' => $this->t('Translate layout'),
+      '#weight' => -9,
+      '#attributes' => ['class' => ['button']],
<strong>+      '#url' => Url::fromUserInput(
+        Url::fromRoute('<current>')->toString() . '/translate'
+      ),</strong>
+      '#access' => $is_enabled && $is_translatable,
+    ];
+

I've attached a quick fix patch that solves the problem for me, can be useful for someone else as well.
(Maybe it can give an idea for a permanent fix - but it's not intended to be the permanent solution itself.)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

thomasdbcklr’s picture

Tested with Drupal 9.2.5. Installed both override issue #238 and this issue #48.

Getting a 404 'page not found' when trying to translate a layout while the url looks fine: '/admin/structure/types/manage/[bundle]/display/[viewmode]/translate'

#49 Did not apply for me

nginex’s picture

I found another bug which is caused by #48.

The issue is:

I expect that for multilingual site when we clear cache in CLI, it should clear everything including field definitions cache BUT the patch from #48 adds layout_builder_config_translation_info() which is triggered after cache clear and it recreates cache of field definitions from scratch and might use different config override language than current language. If there is mismatch there will be a moment when you can see field labels in one language while your interface language is another language.

Here is improved patch which fixes the described above issue.

kostyashupenko’s picture

Issue tags: -Needs reroll

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

Priority: Normal » Major

Updating the priority to Major as of the priority of the META issue. It would be expected to be able to translate all elements provided by core, but that's still not the case here. For default layouts, the labels and inline blocks still can't be translated.

Confirming this still needs work, the button "Translate layout" links to a non-existing page:
- /admin/structure/types/manage/aircraft/display/default/translate = 404 (Page not found)
- /admin/structure/types/manage/aircraft/display/translate = 403 (Access denied - with admin!)

The layout was created prior to applying the patch.

anybody’s picture

Created an issue fork from #52 (1:1) to proceed there. We should really get this fixed for 9.4, the current situation isn't appropriate for multilanguage sites with layout builder.

matthijs’s picture

The patch from #52 has an issue when using domain-based language selection, an exception is thrown because Url::fromUserInput() gets an absolute URL. The attached patch fixes this.

anybody’s picture

Played around with the patch from #49 but wasn't successful, so reverting the MR to the previous state. My key problem is that I don't even understand which path / route is expected here. The current and the proposed solution both seem dirty?

What's the expected path for display layout translation? I can't get any working.

anybody’s picture

@Matthijs could you please provide an interdiff or fix it in the MR?

matthijs’s picture

@Anybody: done!

anybody’s picture

MR is missing the newly added files from the patch. I'll fix this asap, seems I forgot the git add -.-

anybody’s picture

anybody’s picture

MR should be fine so far, but I still get "Access denied" in the generated path:
admin/structure/types/manage/{NODE-TYPE}/display/translate
with user 1 (admin)

Any ideas?
This happens despite whatever I configure for translation settings on the node type. Even if translation is enabled, disabled, language set to a specific language, etc.

matthijs’s picture

StatusFileSize
new39.97 KB

Some changes were missing in my previous patch (seems i forgot to "git add" as well), here the new one.

matthijs’s picture

StatusFileSize
new40.05 KB

Fixed missing use statement.

anybody’s picture

@Matthijs: FYI you can always very simply create a patch file from Merge Request URL + ".diff" or click the "plain diff" link above:
https://git.drupalcode.org/project/drupal/-/merge_requests/1921.diff

So you don't have to create the patch file yourself with such risks.

anybody’s picture

Issue summary: View changes

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nginex’s picture

StatusFileSize
new40.53 KB

Here is an improved d10 version of the patch based on #66 patch.

Tried to create an interdiff but it failed. Also if we use MR approach we need to switch the target branch for the fork and rebase it.

nginex’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

For the CC failure.

But can the IS be completed also, with the proposed solution

And if this requires #2946333: Allow synced Layout override Translations: translating labels and inline blocks then this should be postponed till that lands.

hitchshock’s picture

StatusFileSize
new40.51 KB

The last patch isn't compatible with the event dispatcher. The first argument must be an event object.
Updated a patch a bit.

hitchshock’s picture

Also, the code if ($section_storage->getTranslatedComponentConfiguration($component->getUuid())) { in LayoutEntityDisplayMapper::hasTranslatable() breaks the 'Translate layout' feature on the content view mode.

How to reproduce it:
- enable config_translation module
- enable layout builder for content type
- configure Layout Builder for some view mode
- try to make a translation of the layout

I see two issues here:
- The ConfigTranslationOverviewAccess::doCheckAccess() uses hasTranslatable() function and in this case $section_storage doesn't have language context
- even I'll add the language context the result still will be wrong, cuz getTranslatedComponentConfiguration() expects that config already contains the translation, it means that it doesn't work for 'add' translation action

circuscowboy’s picture

I am trying to solve the layout builder translation issues for the first time and I am running into difficulties.

If I use patch 75 on its own I get the following error message:

Error: Interface "Drupal\layout_builder\TranslatableSectionStorageInterface" not found in /var/www/pwnhc/web/core/modules/layout_builder/src/DefaultsSectionStorageInterface.php on line 12 #0 /var/www/pwnhc/vendor/composer/ClassLoader.php(571): include()

If I apply the patch in this issue, https://www.drupal.org/project/drupal/issues/2946333 based off this merge request https://git.drupalcode.org/project/drupal/-/merge_requests/5956#note_259636 then that error goes away and I get a button called "Translate Layout".

The old merge request listed above (https://git.drupalcode.org/project/drupal/-/merge_requests/1504#note_194458) no longer applies to 10.2 - If this new patch would have fully worked I would replace it in the description.

I am having 2 issues with the 2 patches. Firstly I am using a path based URL and the path is duplicated in the Translate Layout button link so it goes to a page not found.

Details

Secondly with the corrected link I gotten 2 different outputs

  1. An access denied error on the page. This was on an existing content type
  2. On a new content type I go this: Error: Call to a member function get() on null in Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->getTranslatedComponentConfiguration() (line 481 of /var/www/pwnhc/web/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php).

If anyone can guide me to get better results I would appreciate it.

sboden’s picture

As documented in https://www.drupal.org/project/drupal/issues/3420019 patch #72 correctly applies to a Drupal 10.2.2 instance, but it breaks the site.

pjonckiere’s picture

StatusFileSize
new32.4 KB

Rerolled for D10.3

pjonckiere’s picture

Issue tags: +DevDaysBurgas2024
liquidcms’s picture

Sorry, lost in where this is at. I swear (back in D9 at some point) i had tabs when in LB and one of those was to "Translate layout"; but now (D10.2.2.) NO tabs.

I have a vanilla D10.2.2 site with these patches:
- https://www.drupal.org/files/issues/2024-06-28/3044993-79.patch
- https://www.drupal.org/files/issues/2024-03-15/2946333-327_Revised_patch...

Additionally:
- Article type set to be translatable
- Basic block set to be translatable
- Article default view mode set to use LB (for all nodes)
- Add inline basic block using LB

There is no apparent UI to access translation of this. I have tried a couple urls as mentioned above:
en/admin/structure/types/manage/article/display/translate - access denied
en/admin/structure/types/manage/article/display/default/translate - throws:

Error: Call to undefined method Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage::getTranslatedComponentConfiguration() in Drupal\layout_builder\ConfigTranslation\LayoutEntityDisplayMapper->hasTranslatable() (line 55 of E:\www\SSC\d10.0\web\core\modules\layout_builder\src\ConfigTranslation\LayoutEntityDisplayMapper.php).

Any hints?

liquidcms’s picture

switched to patch from #75 and now i see a Translate Layout button (at least now i know what the expected ui is); but it throws this error:

Error: Call to a member function get() on null in Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->getTranslatedComponentConfiguration() (line 481 of E:\www\SSC\d10.0\web\core\modules\layout_builder\src\Plugin\SectionStorage\DefaultsSectionStorage.php).

liquidcms’s picture

and now, magically, button gives Access Denied at: en/admin/structure/types/manage/article/display/translate

l_vandamme’s picture

StatusFileSize
new31.9 KB

Rerolled patch for 11.x (using my rebase commit of https://www.drupal.org/project/drupal/issues/2946333 MR 5956)

l_vandamme’s picture

StatusFileSize
new32.16 KB

Woops, missed an import in my patch

mahde’s picture

@l_vandamme The last patch doesn't apply to the latest Drupal 11.

rodrigoaguilera’s picture

StatusFileSize
new8.28 KB

Reroll attached of #85 applied agains Drupal 11.2.2 (with #356 from here also applied)

rodrigoaguilera’s picture

StatusFileSize
new32.23 KB

#87 is an incomplete patch, here is the right version

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.