Option to share files between translations
drewish - July 4, 2008 - 06:01
| Project: | Internationalization |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Now that translations are in core it would be very cool if the field had an option to share the file between translations. Some files like images would be language neutral and it doesn't make sense to duplicate the file between each translation node. I think it should an option rather than the default because for some files like translated PDFs each file would be unique to for the node.
Thoughts? If you're interested I'll start working on a patch.

#1
Absolutely important. But how does what you propose differ from what Filefield does now? It already suits my needs ;)
I have a custom node-type with a Filefield_Image defined. When I create a node in one language and upload an image, then translate it, the image is already there in the translation. But maybe I'm not understanding what you mean.
#2
that's what i get for posting without testing fully. you're right i it does seem to do that. i guess then the the issue really becomes making it optional.
#3
I haven't tested extensively but so far it seems to work. Making it optional would be a good feature, +1
#4
If you're going to work on this, what I think would be a great feature for multilingual support is something of a 'synchronize afterwards' function, that shares files/images between the translations.
I wrote that it works for me, and it does, but only if I translate a node with an image already attached. If I translate the nodes and later add a file, it does not get shared, i18n/translation's synchronize function does not work here (although it gives an option ´synchronzie attached image')
#5
i'd think that if you check this box all your translations would share the same files, uploading to one uploads to alll, deleting from one deletes from all, etc. i18n is in pretty poor shape right now and i think that now that translations are in core the module should offer some support for this.
i'm just getting my data migrated into filefield from upload module right now so i'll probably start working on this next week.
#6
Looking forward to that ;)
#7
this should probably be more generic than just in filefield. there are many types of fields where you might want this optional functionality.
of course, i'm speaking without having touched i18n in over a year, so ignore me if that seems unreasonable.
#8
With the translations... The new version FileField does allow files to be shared between nodes... as for the relationships between the field data and the node, that is CCK's job.
#9
Still, in current version 3.0-rc1 there is a bug (partly described in #4)
I added new file field for 'Story' content type & checked 'Synchronize translations' box for this field.
Then I created a new story & uploaded some files. When I created a translation - it had that files. But when I added a file to one translation, it didn't appear in the other.
It does not seems to be a CCK bug, because 'Synchronize translations' works for other fields, e.g. with 'link'.
#10
This looks like an unfinished task within the i18n_sync.module:
<?php// TODO take type specific actions.
case 'filefield':
case 'imagefield':
break;
?>
Currently the logic is unimplemented.
#11
I just have this problem (need to synchronize filefield between my translations). I resolve the situation by simply commenting these 3 lines (264,265,266):
<?php// TODO take type specific actions.
//Fix the syncronize translation for filefield *mod_module
//case 'filefield':
//case 'imagefield':
// break;
?>
I do not know what was the logic to implement for filefield but it works well with the code included in the default case.
Ps: thanks quicksketch for pointing out where the problem was, that saved me a lot of search time.
#12
I have followed just1's instructions and it seem to work.
But I wonder if this has any side effects. Maybe the authors of this module had some kind of intention when using the switch statement. Any ideas?
#13
Check out dasjo´s patch: http://drupal.org/node/426478#comment-1764910
It worked for me. Could be a possible fix.
#14
here is my patch from http://drupal.org/node/426478#comment-1764910 which treats filefield and imagefield equally.
#15
I got
warning: Invalid argument supplied for foreach() in [...]/drupal6/sites/all/modules/i18n/i18nsync/i18nsync.module on line 376.the first time I tried dasjo's patch at #14. But later synchronizing does not give the error anymore.I tried #10 and it also worked.
#16
Using FileField 3.0 beta1 or higher (we're now at 3.1), it's unnecessary to differentiate between filefield and imagefield, since an imagefield now actually IS a filefield as far as data is concerned. ImageField is just a widget on top of the field provided by FileField. So you should be able to remove
case 'imagefield':entirely.#17
Ok, added some additional check (is_array) and committed. Thanks.
#18
Automatically closed -- issue fixed for 2 weeks with no activity.