diff --git a/weight.module b/weight.module index a814103..f61674d 100644 --- a/weight.module +++ b/weight.module @@ -371,6 +371,17 @@ function weight_views_submit($form, &$form_state) { $node = $nodes[$nid]; $node->weight_weight = $values['weight'][$key][$nid]; _weight_set_weight($node); + + //i18n_sync integration, update translations if "sticky" sync is enabled + if (module_exists('i18n_sync') && in_array('sticky', i18n_sync_node_fields($node->type))) { + $translations = translation_node_get_translations($node->tnid); + if (count($translations)) { + foreach ($translations as $translation) { + $translation->weight_weight = $node->weight_weight; + _weight_set_weight($translation); + } + } + } } drupal_set_message(t('Weights saved successfully.')); @@ -548,3 +559,27 @@ function _weight_set_defaults($default, $type) { ->execute(); } } + +/** + * Implements hook_i18n_sync_translation + * + * Perform synchronization on translations if "stycky" sync is enabled + * + * @param $entity_type + * @param $translation + * Translated entity. + * @param $translation_language + * Translated entity language code. + * @param $source + * Source entity. + * @param $source_language + * Source entity language code. + * @param $field_names + * Array of field names to synchronize. + */ +function weight_i18n_sync_translation($entity_type, $translation, $translation_language, $source, $source_language, $field_names) { + if (in_array('sticky', $field_names)) { + $translation->weight_weight = $source->weight_weight; + _weight_set_weight($translation); + } +}