Let layout builder render inline block translations

Created on 6 October 2021, about 3 years ago
Updated 13 November 2024, 8 days ago

Problem/Motivation

If you translate inline blocks (also with tmgmt), layout builder doesn't recognise the translation.

Steps to reproduce

Translate inline blocks with tmgmt and the patch on the related issue.
Go to translated page and the content stills in its original language.

Proposed resolution

Apply the patch on the relates issue to let tmgmt translate inline blocks.
Make layout builder read translated content.

Remaining tasks

For doing this with paragraphs you need to add the "translation" tag on the twig template. You also need twig tweak module to use the translation tag. Doing this without altering twig template will be awesome.
Needs test files.

User interface changes

API changes

Data model changes

Release notes snippet

Instructions for translating layout builder blocks with/o paragraphs and tmgmt:
** These instructions asume you have configured a translation provider
for tmgmt.

1- Apply both patches.

2- Enable layout builder on a specific content type from the manage form
display tab.

3- Add a language to Drupal at /admin/config/regional/language/add

4- Enable the translations for the content type and the required blocks
and paragraphs if needed at /admin/config/regional/content-language.

5- Disable the "Users may translate this field" for each nested paragraph
field for a certain entity type like inline blocks or content entities.
This can be found at /admin/structure/types/manage/my_entity_type/fields.
For more information on this step please visit:
https://www.drupal.org/docs/contributed-modules/paragraphs/multilingual-...

6- Create content of the content type where the layout builder was
enabled.

7- Once the content is created go to the Layout Tab, add a custom or
library block and save the layout.

8- Go to translation tab.

9- Make sure "Add layout blocks to translation job" is checked.

10- Check the desired target language and click "Request translation"
button. You will be redirected to the translation job page.

11- Click "Submit to provider button.

12- Depending on the provider the transltion could require some time.
If you are working with the provider testing environment the translation
can take at least 15 minutes.

13- Go to the translation jobs page at /admin/tmgmt/jobs.

14- Click "Manage" button to the left of the item row.

15- Click the "Auto-import" button. You will be redirected to the
translation jobs page. If the translation is ready you will se and
orange icon next to the translation, otherwise a message will be
displayed to inform there aren't translations to import yet.

16- Once the translation is ready, click again on the "Manage" button.

17- Now its time to review the translaton by clicking the "View" button
next to each item to be translated.

18- If the translated text is correct, click on "Save as completed"
button. Make this for each item to be translated.

19- If the block to translate contains paragraphs you need to modify the
twig template for the required block adding the following tag:
{% set entity = item.entity|translation %}
Then you can render a field with the following grammar:
{{ entity.field_my_custom_paragraph.value }}

20- Visit the translated conntent and now you can see the translated
content.

Feature request
Status

Needs work

Version

11.0 🔥

Component

layout_builder.module

Created by

🇪🇸Spain alvarodemendoza

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024