Allow to translate entity reference fields that reference content

Created on 1 July 2025, about 1 month ago

Problem/Motivation

Currently fields that entity reference gets added to the batch but doesn't get handled or translated. so this automatically translate referenced content entities (e.g., nodes) when translating a parent node.

Steps to reproduce

Proposed resolution

  1. Field Scanning:
    During the translation process, all fields of the node are scanned. If a field is of type entity_reference and targets the node entity type, it is marked for recursive translation processing.
  2. Referenced Node Loading:
    Each referenced node is loaded using its target_id. The system ensures the referenced node exists and is a valid content entity (i.e., an instance of NodeInterface).
  3. Translation Check:
    For every referenced node, the system checks if it already has a translation in the target language. If the translation exists, it skips further processing for that node. If not, it prepares to translate it.
  4. Cycle Detection:
    To avoid infinite loops caused by circular references (e.g., Node A → Node B → Node A), the system keeps a list of visited node IDs in the current translation chain. If a node is already in the visited_nodes array, it will be skipped to prevent recursion loops.
  5. Recursive Translation:
    If the node hasn't been translated and isn't in the visited list, its ID is added to visited_nodes, and the system recursively invokes the translation logic (e.g., via formTranslate()) to create its translation.
  6. Logging and Finalization:
    The system logs successful translations and skipped nodes (due to cycles or errors) for traceability. Once all referenced nodes are processed, the original node’s translation continues or finalizes.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.4

Component

Code

Created by

🇯🇴Jordan Ibrahim Tameme

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024