tableau-mkt-archived / entity_xliff

Drupal module that provides an API for entity serialization in the XLIFF format.
https://drupal.org/project/entity_xliff
2 stars 0 forks source link

XLIFF imports for existing content with paragraphs overwrites source paragraphs with translation #88

Closed iamEAP closed 8 years ago

iamEAP commented 8 years ago

Net-new imports of content with Paragraphs work as expected... However, if content that includes paragraphs is imported over an existing translation, the translations on the import will overwrite the source content (irrevocably losing the source content).

iamEAP commented 8 years ago

Regression test for this confirms that only Paragraphs are affected. Neither field collections nor standard entity references are impacted.

iamEAP commented 8 years ago

Further investigation reveals that this may be a bug in Paragraphs itself...

$node = entity_metadata_wrapper('node', $nid_of_translation);
$node->field_paragraphs->value();
// Yields English paragraphs.

Edit: Aaand even further investigation reveals that it's a firing order thing...

// Yields translated paragraphs.
$node = entity_metadata_wrapper('node', $nid_of_translation);
$node->field_paragraphs->value();
// Yields source paragraphs.
$source = entity_metadata_wrapper('node', $nid_of_source);
entity_xliff_get_translatable($source)->getTargetEntity('fr')->field_paragraphs->value();

// Yields source paragraphs.
$target = entity_metadata_wrapper('node', $nid_of_target);
$target->field_paragraphs->value();