Layout Builder Asymmetric Translation
Enables asymmetric (different) layout overrides for each translation of content entities using Layout Builder.
layout_builder_at
Install
composer require 'drupal/layout_builder_at:^3.0'
composer require 'drupal/layout_builder_at:8.x-2.15'
Overview
Layout Builder Asymmetric Translation allows you to configure different layouts and blocks for different language translations on content items that use Layout Builder overrides. This solves the common multilingual challenge where different languages need different layout arrangements.
For example, if an Article node needs to display two additional blocks that aren't present on other Article nodes, the English translation can show Block A on the left and Block B on the right, while the German translation can show them in reverse order - Block A on the right and Block B on the left.
The module works by making the layout section field translatable. When Layout Builder is enabled on an entity display, the module automatically makes the layout_builder__layout field translatable. This allows each translation to maintain its own independent set of sections and blocks.
The module also provides a field widget that can optionally copy blocks from the source translation when creating a new translation, allowing editors to start with the same layout and then modify it as needed for the target language.
Features
- Allows different Layout Builder layouts and block arrangements for each language translation of a content entity
- Automatically makes the layout_builder__layout field translatable when Layout Builder is enabled on an entity type
- Makes existing layout section fields translatable upon module installation
- Provides a 'Copy blocks into translation' checkbox widget that appears when creating new translations
- Three widget appearance modes: unchecked (default), checked, or checked and hidden for automatic copying
- Inline blocks added to layouts automatically inherit the language of the entity they are attached to
- Properly handles inline block dependencies with correct translation context
- Cleans up translation-specific tempstore data when a translation is deleted
- Supports Entity Reference Revisions fields within inline blocks during replication
- Removes Layout Builder's non-translatable field warning from the language content settings table
Use Cases
Different promotional blocks per language
A marketing website needs to show different promotional banners and call-to-action blocks for English and German audiences. With this module, the English version can display a 'Summer Sale' banner on the right sidebar while the German version shows a 'Sommerschlussverkauf' banner on the left sidebar with different imagery.
Language-specific content ordering
A news site displays related articles differently based on reading direction. The English layout shows related articles on the right side, while the Arabic translation displays them on the left to accommodate right-to-left reading patterns.
Region-specific blocks
An e-commerce site needs to show payment provider blocks that vary by region/language. The US English version shows PayPal and credit card blocks, while the German version shows Klarna and SEPA direct debit blocks in different positions.
Starting translations from existing layouts
When creating a French translation of a page with complex layout, editors can check 'Copy blocks into translation' to duplicate all existing blocks and their positions, then modify only what's needed for the French audience instead of rebuilding from scratch.
Automatic block copying workflow
Configure the widget as 'Checked and hidden' for content types where translations should always start with the same layout as the source language, streamlining the translation workflow by automatically copying all blocks.
Tips
- Use the 'Checked and hidden' widget setting for content types where you always want blocks copied to new translations automatically
- When copying blocks, inline block content is fully duplicated, creating independent copies that can be edited separately per translation
- The module automatically makes existing layout fields translatable upon installation, so you don't need to recreate fields
- Entity Reference Revisions fields (like Paragraphs) within inline blocks are also properly duplicated when copying blocks
- After module installation, remember to enable translation for the Layout field in Content language settings for each entity type
Technical Details
Admin Pages 1
/admin/config/regional/content-language
Enable translation for the Layout Builder layout field on your entity types. This is a core Drupal page where you configure which fields should be translatable per entity type.
Hooks 9
hook_module_implements_alter
Removes Layout Builder's form_entity_form_display_edit_form_alter implementation to replace it with the module's own implementation that allows the layout field to be configured in form display when it's translatable.
hook_theme_registry_alter
Removes Layout Builder's preprocess function for language_content_settings_table to eliminate the 'Non translatable' warning message since this module makes layout fields translatable.
hook_form_entity_form_display_edit_form_alter
Modifies the entity form display edit form to show the layout field configuration when it's translatable, and adds validation to prevent selecting the default Layout Builder Widget.
hook_form_alter
Modifies entity forms to show the 'Copy blocks into translation' checkbox with appropriate label when the layout_builder_at_access flag is set on the widget.
hook_layout_builder_section_storage_alter
Replaces the core OverridesSectionStorage class with TranslatableOverridesSectionStorage to allow access to the Layout tab on translations.
hook_field_storage_config_presave
Makes layout_section fields translatable when they are saved. This enables asymmetric translations for Layout Builder overrides.
hook_form_layout_builder_add_block_alter
Sets the default language of inline blocks to match the entity language when adding blocks via Layout Builder. This behavior can be disabled via settings.php.
hook_entity_translation_delete
Cleans up the Layout Builder tempstore when an entity translation is deleted, removing any unsaved layout changes for that translation.
hook_install
Makes all existing layout_section fields translatable when the module is installed (except during config sync).
Troubleshooting 5
Ensure the layout_builder__layout field is enabled for translation at Administration > Configuration > Regional and language > Content language. Check the checkbox for the Layout field under your entity type.
Configure the Manage form display for your entity type and set the layout_builder__layout field to use the 'Layout Builder Asymmetric Translation' widget instead of the hidden or default widget.
By default, inline blocks inherit the entity's language. If you don't want this behavior, add $settings['layout_builder_at_set_content_block_language_to_entity'] = FALSE; to your settings.php file.
This validation error occurs because the original Layout Builder widget doesn't support asymmetric translations. Select the 'Layout Builder Asymmetric Translation' widget or hide the field in form display.
These two modules are mutually exclusive and cannot be used together on the same site. Choose one approach: asymmetric (different layouts per language) or symmetric (same layouts across languages).
Security Notes 2
- The module uses Drupal's core security coverage and follows Drupal's entity access patterns
- Block copying respects entity access permissions - users need appropriate permissions to create and edit custom blocks