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

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

ibrahim tameme created an issue. See original summary.

ibrahim tameme’s picture

This patch include translating entity reference taxonomy fields labels only, It will not translate anything else in the taxonomy.

bigbabert’s picture

Category: Task » Support request

Hi @ibrahim tameme,

thanks for the support request i think that it make sense but the patch not seems related to the task, the module already allow to auto translate taxonomy entities and fields from taxonomy term translate form, i'll check if you patch can be extended to translate all the field of the taxonomy term too and the request in the issue description.

Best regards

  • bigbabert committed 7786856d on 1.0.x
    amazon translate provider + Issue #3533327 by ibrahim tameme: Allow to...
bigbabert’s picture

Hi @ibrahim tameme,

the version 1.5.0 is including the feature could you have a test to confirm that work as expected?

Best regards
Alberto

bigbabert’s picture

Status: Active » Needs review

  • bigbabert committed 7786856d on 1.4.x
    amazon translate provider + Issue #3533327 by ibrahim tameme: Allow to...
borutpiletic’s picture

StatusFileSize
new19.22 KB

@bigbabert Not sure if its a bug or not?
When I use the bulk translation action it will translate referenced entities but those translated referenced entities will be set to published no matter the current setting for "Bulk Translations - Publish Mode" set to "Draft".

Bulk settings

bigbabert’s picture

Hi @borutpiletic,

yes it seems a bug, are you testing with the patch in this issue or with latest module version?
Will need also to verify that already translated contents are not translated twice when referenced.

Best regards

bigbabert’s picture

Status: Needs review » Needs work
borutpiletic’s picture

Hi @bigbabert
Found this issue in version 1.4.37