Want to get Lullabot article, videocast, and podcast announcements delivered right to your in-box?
Let us know your email address (we won't share it) and we'll let you know when anything exciting happens.
Making Attachments Appear Across Translations
Drupal 6 supports translation of content with the core Content Translation module. So you can create a page in English, then translate the page to Dutch.
But what if you attach a file to the English page? It does not show up on your Dutch translation. And what if you are using CCK and FileField? That's the case that I want to cover in this article.
First, I installed Drupal 6.6, enabled the Locale module, and added the Dutch translation (for the proper way of installing translations, see Addison Berry's screencast, Installing Drupal with a Translation).
I installed CCK 6.x-2.1 and enabled the Content module and some others (Node Reference, Number, Text, Option Widgets).
I installed the 6.x3.x-dev snapshot of FileField (it's better to use an actual release but I saw some bug fixes going into the module and figured I'd test it). I enabled FileField module.
I enabled the core Content Translation module.
Then I installed i18n 6.x-1.0-BETA6, which is the latest release of the Internationalization Module. I enabled the Internationalization and Synchronize Translations modules.
I needed a CCK content type to test with so I created one:

I created a CCK field called Audio to hold audio files:

Then I adjusted the new content type's workflow settings to enable multilingual support and synchronization of the CCK field:

Now I was ready to enter some content. I created a node in English with an attached music file:

Then I used the "add translation" operation of the Translate tab to add a Dutch translation.

The audio field could be seen on the node editing form, and the resulting Dutch translation contained the attachment.

Sharp-eyed readers will notice that on the workflow settings options for the content type, I also have Attachments enabled (and I've got the core Upload module enabled), but I didn't check File attachments under the Synchronize translations section of the workflow settings. That means that I can attach files using the Audio field and they will be synchronized across translations, but I can attach files using the regular File Attachments method and they will not be synchronized, so I can also have a separate file per translated node. The best of both worlds!
The Synchronize Translation module can be used to do much more than synchronize CCK fields; it can also synchronize taxonomy terms, comment and node settings, etc. Here we have just scratched the surface of its capabilities by using it to synchronize a CCK filefield across translations.
For more information on Drupal's internationalization capabilities, see the Drupal Handbook, the Internationalization Drupal Group, chapter 18 of Pro Drupal Development, or chapter 8 of Using Drupal.





Comments
Sure that worked but the
Sure that worked but the English original and the Dutch translation are actually 2 different nodes. This means the comments on the English node is not viewable on the Dutch node and vice versa. This doesn't really make sense, does it?
I think rather than creating a new node and duplicating all its fields and store their relations in the node table's tnid, nid, language fields, a better way would be to duplicate all the fields within the node being translated. This way, we can keep all translations within the same nid, which makes more sense, doesn't it?
Separate nodes
@cloneofsnake: having separate nodes allow for maintaining revisions in both nodes (so you can view differences of changes made), knowing authors for the different versions, being able to attach different workflows, count visitors to the two nodes separately, letting them show up in feeds separately, etc. You might think that displaying comments in Dutch on an English node is logical, others might thing English speaking people might not be able to read Dutch, so it is best to keep Dutch comments on Dutch nodes and not mix with English.
The idea behind having separate nodes as a base, and then supporting synchronizing different data (eg. taxonomy, fields, etc) is that you can have all the advantages of different nodes if you need them.
Side effect
Great article John!
On http://musescore.org , we use this setup as well for maintaining handbooks in several languages. The Synchronize Translations modules are ideal for our use case: if an attached file (e.g. screen shot) is changed, it will be propagated to the translations as well.
However, there is a side kick with synchronized translations. When one edits a node, not only is there a new revision created for this node, but for all the node translations as well. This might be exactly what you need, but in some cases, it might be quite redundant: in case no attachment was changed for a new revision, even then it will sync the node translations and create a new revision for each of them.
Up until today, I have not found a solution for this. Perhaps, a contrib module could check whether there is really something changed for the fields which needs to be synced, just before the node is submitted. In case of no change, don't sync (bc there is nothing to sync).
Anyone an elegant solution for this?
Synchronised revisions
toemaz, if you look again at the screenshot where John sets the 'Audio File' to sync across translations, you'll see there is also a checkbox for 'Revision (Create also new revision for translations)'.
You just need to uncheck that box.
unchecked
I'm using D6 and the latest dev version of i18n. This revision checkbox has always been unchecked in my translation workflow. Still, it creates new revisions for each translation.
I don't think this checkbox was intended to solve the question I have, but rather sync the revision field of the node.
I've been digging into the code and tried to develop a solution. I opened an issue for it at http://drupal.org/node/338756
Post new comment