ContentEntitySource is using entity's source language instead of job's source language when saving

Created on 11 October 2021, over 2 years ago
Updated 1 December 2023, 7 months ago

Problem/Motivation

In saveTranslation function of the ContentEntitySource, it loads the job's entity and pass it to the doSaveTranslations. However, it doesn't load the correct translation based on the job's source language so it will default to the node's source language. In our case, we use paragraphs_asymmetric_translation_widgets so paragraph structure could be different between the node's source language and job's source language and that causes a field mismatch error when trying to save a translation job as completed.

Steps to reproduce

Enable tmgmt and paragraphs_asymmetric_translation_widgets. Create a node (langcode: en) with nested paragraph fields (e.g. Paragraph type A, Paragraph type B), then create a translation of the node (langcode: en-au) with nested paragraph fields (e.g. Paragraph type C). Request a translation of the node from en-au -> fr and the exported node data will be created based on en-au so Paragraph type C's fields will show in the translation xliff file.

If you import the completed xliff file and try to save the job as completed, it will error out as it will load the en version of the node when executing the saveTranslation

Proposed resolution

In saveTranslation, the job's source language should be taken into consideration when loading the entity. Plus, it should do no harm to people who doesn't use paragraphs_asymmetric_translation_widgets.
Something like: $entity->getTranslation($job_item->getJob()->getSourceLangcode())

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Source: Entity

Created by

πŸ‡¦πŸ‡ΊAustralia peterwcm

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.69.0 2024