? .buildpath
? .project
? .settings
? i18n-526478-5.patch
Index: i18nsync/i18nsync.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18nsync/i18nsync.module,v
retrieving revision 1.1.2.26
diff -u -p -r1.1.2.26 i18nsync.module
--- i18nsync/i18nsync.module	12 Jun 2009 13:35:12 -0000	1.1.2.26
+++ i18nsync/i18nsync.module	1 Jul 2009 17:22:11 -0000
@@ -261,8 +261,11 @@ function i18nsync_node_translation($node
     if (isset($content_fields[$field]) && isset($node->$field)) {
       switch ($content_fields[$field]['type']) {
         // TODO take type specific actions.
+        
+        // Filefields and imagefields are syncronized equally.
         case 'filefield':
         case 'imagefield':
+          i18nsync_node_translation_filefield_field($node, $translation, $field);
           break;
 
         case 'nodereference':
@@ -362,6 +365,30 @@ function i18nsync_node_translation_noder
 }
 
 /**
+ * Translating an filefield (cck).
+ */
+function i18nsync_node_translation_filefield_field(&$node, &$translation, $field) { 
+  $translated_files = array();
+  foreach ($node->$field as $file) {
+    $found = false;
+
+    // Try to find existing translations of the filefield items and reference them.
+    foreach ($translation->$field as $translation_image) {
+      if ($file['fid'] == $translation_image['fid']) {
+        $translated_images[] = $translation_image;
+        $found = true;
+      }
+    }
+    
+    // If there was no translation found for the filefield item, just copy it.
+    if (!$found) {
+      $translated_images[] = $file;
+    }
+  }
+  $translation->$field = $translated_images;
+}
+
+/**
  * Helper function to which translates reference field. We try to use translations for reference, otherwise fallback.
  * Example:
  *   English A references English B and English C.
