After some debugging I've discovered that the "translate and reference" provided by noderelationships module doesn't work with syncronized fields.

The _noderelationships_nodeapi_prepare_translation() works fine: it correctly set up the translate_and_reference[] array on the $node variable, but after doing that, the i18nsync module (i18nsync_prepare_translation() rewrites the value.

The issue can be solved with a small fix. The if-else block is executed only when the field has not already been manipulated by noderelationships:

Original source code:

        if (isset($content_fields[$field]) && isset($source->$field)) {
          switch ($content_fields[$field]['type']) {
          case 'nodereference':
            i18nsync_node_translation_nodereference_field($source, $node, $field);
            break;
          default:
            // For fields that don't need special handling.
            $node->$field = $source->$field;
          }
        } else {
          $node->$field = $source->$field;
        }

Fixed code:

        // load the field value
        $field_value = array();
        $field_value = $node->$field;

        // check if the field value has already been processed by noderelationships module
        if (!isset($field_value['0']['translate_and_reference'])){ // check the translate_and_reference status
          if (isset($content_fields[$field]) && isset($source->$field)) {
            switch ($content_fields[$field]['type']) {
            case 'nodereference':
              i18nsync_node_translation_nodereference_field($source, $node, $field);
              break;
            default:
              // For fields that don't need special handling.
              $node->$field = $source->$field;
            }
          } else {
            $node->$field = $source->$field;
          }
        } // --

I don't know if there is a better fix, anyway it just works.

Comments

marinex’s picture

Hi I looked at i18nsync.module 1.9 ver. but I did not found your "Original source code"... can you help me where is the function you fixed? Thank you M.

marinex’s picture

After I take a look at another issue I assume this fix must be applied after this Translating a nodereference field doesn't work when creating a translation

finex’s picture

@marinex: you're right, I've forgot to mention it :-) Thanks!

finex’s picture

Issue summary: View changes

Corrected module name.

joseph.olstad’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)