CodersCare / l10nmgr

GNU General Public License v3.0
0 stars 9 forks source link

Container-Child Elements are not translated, if container parent is not part of export #37

Closed rvock closed 9 months ago

rvock commented 9 months ago

Steps to reproduce:

  1. Install container-extension
  2. Add a container parent with a child element
  3. Translate container parent and child element
  4. Add a new Child element and create an export with l10nmgr
  5. Translate the XML and import it
  6. The new element will not be created in the translation

The bug exists, because l10nmgr checks if the container extension is installed and the element is a child-element. If that's the case, l10nmgr assumes, the element will be created when the parent is localized. But that's not the case if it is not part of the export.

Relevant Code-Position: https://github.com/CodersCare/l10nmgr/blob/3ee71720066bafdf2c5abd736c1f97c6f3ae61ec/Classes/Model/L10nBaseService.php#L732-L741

The condition should be updated and also check if the container parent is part of the export:

 && isset($inputArray['tt_content'][$element['tx_container_parent']])
rvock commented 9 months ago

My initial fix containted a bug. The $inputArray gets modified and processed elements are removed. This means the check will return false.

Updated Fix: Copy $inputArray at the start of the method. Then check for the copy:

$originalInputArray = $inputArray;
foreach ($accum as $pId => $page) {
...
if (ExtensionManagementUtility::isLoaded('container') && $table === 'tt_content' && $element['tx_container_parent'] > 0 && isset($originalInputArray['tt_content'][$element['tx_container_parent']])) {
Cybercraft-GmbH commented 9 months ago

There should be no check if the container is in the export, but the other way around: The container has to be found and triggered, so that it will execute a "localize/synchronize" command before the actual content is filled in.

There is a configuration that deals with this kind of parent child relation:

` /*

Just configure that for container fields and it should be working as expected.

If it doesn't, feel free to reopen the issue.