The translation sync is not working for me as expected. If I select all the node options/fields to be sync'd and translate a node, I arrive at an empty node (instead of it being pre-filled). If I don't select to translate, they are pre-filled, but not sync'd. I remember in D6 having sync'd fields pre-filled upon translation, or am I wrong?

Comments

rp7’s picture

subscribe

fietserwin’s picture

Title: Translation sync not working » Translation sync not working on creating a translation
Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Active » Needs review

Dived into this problem and found out that i18n_sync undoes all the nice work done by field module itself.

Note: we are talking the node translation situation, not the in-node field translation situation.

- field module will, on creating a translation of a node, prepare the node by copying the field values from the original language to the new language (file field.default.inc, function field_default_prepare_translation() called by field.attach.inc: function _field_invoke())
- i18n_sync will prepare the node by copying the fields to the new node thereby overwriting the work of the field module and initializing the fields of the new node with only values for the original language.... (file i18n._sync.module: function i18n_sync_node_prepare()).
- The contents of this function looks a bit like pseudo/placeholder code as there is a switch on a field with name 'taxonomy', while all fields will start with '_field'???

The solution is simple: do not anything at all at node_prepare.

Old code:

function i18n_sync_node_prepare($node) {
  // If creating a translation, copy over all the fields to be synchronized.
  if (empty($node->nid) && !empty($node->translation_source) && ($sync_fields = i18n_sync_node_fields($node->type))) {
    foreach ($sync_fields as $field) {
      if (empty($node->translation_source->$field)) continue;
      switch ($field) {
        case 'taxonomy':
          // Do nothing, this is handled by the i18n_taxonomy module
          break;
        default:
          $node->$field = $node->translation_source->$field;
          break;
      }
    }
  }
}

New code:

function i18n_sync_node_prepare($node) {
  // If creating a translation, copy over all the fields to be synchronized.
  /*
  if (empty($node->nid) && !empty($node->translation_source) && ($sync_fields = i18n_sync_node_fields($node->type))) {
    foreach ($sync_fields as $field) {
      if (empty($node->translation_source->$field)) continue;
      switch ($field) {
        case 'taxonomy':
          // Do nothing, this is handled by the i18n_taxonomy module
          break;
        default:
          $node->$field = $node->translation_source->$field;
          break;
      }
    }
  }
  */
}
jose reyero’s picture

Status: Needs review » Fixed

Most fields should work now.

Moinax’s picture

Great, thanks, I just got the error, and fixed it with the last dev version.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

finex’s picture

This bug is still reproducible on D6 :-(