Support layout builder translations

Created on 24 October 2024, about 2 months ago

Problem/Motivation

Using https://www.drupal.org/project/layout_builder_st/ and https://www.drupal.org/node/3097660 , we can translate inline blocks. Ideally the context utility from Smartling would also support this. However, it doesn't. I gathers the canonical URL from the various inline blocks and attempts to view them. This won't work, because blocks aren't really intended to be "rendered" apart from the page they are placed. Sure, they have a canonical URL, but that is the edit form, not a proper rendering.

Steps to reproduce

  • Setup a vanilla drupal site
  • Install & configure multiple languages and tmgmt_smartling
  • Configure the basic content block provided in the standard install profile to support translations on the body field
  • Activate and configure layout_builder_st
  • Apply latest patch from https://www.drupal.org/node/3097660
  • Configure basic page to support layout builder layouts
  • Add a basic page in english with a basic content block with some english copy in it
  • Send this page over to smartling to be translated and make sure to send over the inline blocks
  • The context uploader attempts to retrieve the block edit URL. This won't work as it isn't the rendering of the block.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

9.0

Component

Code

Created by

heddn Nicaragua

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

Merge Requests

Comments & Activities

  • Issue created by @heddn
  • As I understand you include inline blocks as TMGMT "suggested" items. So, TMGMT creates TMGMT Job items per every requested entity and packs them into TMGMT Job. Our context feature generates a URL from the entity attached to the TMGMT Job item. There is no relation like "this block/incline block/etc is placed/attached on/to the entity from TMJMT Job item (node or something else) in this TMGMT Job". The connector can't guess what entity it needs to pick to render blocks. It just renders the given entity from the job item by whatever link it provides.

    It's also not clear what entity to pick because as I understand inline block could be placed on multiple entities.

    However, you can use hook_tmgmt_smartling_context_url_alter and implement your own rules for overriding context URL. Only you know what page to choose to render block as a context.

  • Merge request !30Resolve #3483245 "Support layout builder" → (Open) created by heddn
  • heddn Nicaragua

    Posted some code in the related MR

  • Pipeline finished with Success
    about 2 months ago
    Total: 3693s
    #321037
  • Hi,

    1. Not sure if it's a good idea to override TMGMT Job Item's item id/type even though it's cloned object.
    2. I initially thought that \Drupal::entityTypeManager()->getStorage($usage->layout_entity_type)->load($usage->layout_entity_id); will return a node or any other content entity but it returns actual layout entity. It only has information that it can work with node of some type but it doesn't have information about the exact node (id).

Production build 0.71.5 2024