Making Attachments Appear Across Translations

Drupal multi-lingual

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:















Drupal create content type screenshot

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















Drupal create audio field screenshot

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















Drupal test type workflow settings

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















Drupal create field instance screenshot

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















Drupal add translation tab screenshot

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















Screenshot of a Drupal node in Dutch

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.

Get in touch with us

Tell us about your project or drop us a line. We'd love to hear from you!