Sometimes it might be necessary for other modules to synchronize custom data or alter the way some synchronizations are done. Currently, there's no other way than patching i18nsync to accomplish this, because writing a custom sync function through hook_nodeapi() will just conflict with i18nsync.

To solve this, a hook_synchronize() could be invoked at the end of i18nsync_node_translation() before node_save().

CommentFileSizeAuthor
#1 i18nsync.patch387 bytesaccount-deletion-needed

Comments

account-deletion-needed’s picture

Status: Active » Needs review
StatusFileSize
new387 bytes

Here's a small patch doing just this. Modules implementing hook_synchronize() should use the following function signature:

/**
* hook_synchronize
*/
function my_module_synchronize($node, &$translation, $op) {

}

$translation needs to be referenced because its node_save() still happens in i18nsync. To synchronize custom fields you can do:

$fields = array('custom_field_1', 'custom_field_2', ...);
foreach ($fields as $field) {
  $translation->$field = $node->$field;
} 
Bevan’s picture

Status: Closed (duplicate) » Needs review
Bevan’s picture

Status: Needs review » Closed (duplicate)

Looks like duplicate of #233787: i18nsync hook to me

Status: Needs review » Closed (duplicate)