Drupal 7 Media Translation Module

Drupal 7 Media Translation Module

Achieve Internet is proud to announce the release of our latest Drupal 7 module, Media Translation, on Drupal.org. This is the third in a series of modules that extend the functionality of the Media Module. This new module allows you to easily translate media files and taxonomy terms into multiple languages. To install the module, go to http://www.drupal.org/project/media_translation.

Related Releases:

Why the Media Translation Module is Useful
Have you ever worked on a multi-language website that used different media files for each language? For example, perhaps your site has video content, and your videos are in different languages. Or maybe your site has installation guides or other content in PDFs or similar formats, all in different languages.

Don't you wish Drupal allowed you to bundle a group of related files and set the language each file is in – and then automatically use the right file on the right translated website without having to manually add the file to each translated node? Well, your dream just came true.

Here’s how it works. The Media Translation module allows you to specify a language for each file you upload through the Media module. Then you can bundle files together in a translation set. If you also use Achieve’s new sub-module Media Translation Display Override, Drupal detects if a referenced file belongs to a translation set and automatically replaces it with the file from the translation set for the language being displayed.

This example walks you through the process:
 
Note: A great time-saver is the PLUpload module, which allows you to upload more than one file at a time. See http://www.drupal.org/project/plupload for more information.
 
  1. Upload the USA version of an image file.

     
  2. Next, upload the files for the other languages, such as the Spanish and Italian versions.

     
  3. Edit each image file and select the language.

    If you leave it as Language neutral, this image will display on all translated sites.

    If you have meta data or associated content for the images, such as Title and Description, enter it now.

    Save each image file.
    Note: The Upload a new file field in the screen shots below allow you to replace an existing file without having to delete the old file and upload a new file. See http://www.drupal.org/project/media_update for more information.


     
  4. Edit one of the image files and click the Translate tab.

     
  5. Associate the related image files. This is called a translation set.

     
  6. Create a node for the USA site, and associate the image with it.

    When you translate the USA node into Spanish, the Spanish image will automatically display (if you are also using the Media Translation Display Override sub-module). This can save you oodles of time because you don’t have to edit the Spanish node and manually add the Spanish image.
A Tip for Managing Translation Sets

The i18n module offers a handy tool for managing, editing, and deleting translation sets – for taxonomies, menus, and now media files.

Go to the Configuration menu, and in the Regional and Language section, select Translation sets.

Installation
  1. Enable the module Media Translation (under the Media section).
  2. Go to the Configuration menu, and in the Media section, select File Types.
  3. For each media file type that will support translations (e.g., images), click manage fields.
  4. Click on the Translate tab.
  5. Select the Translate mode to Translate.
  6. Click Save.
Engineering Challenges

We used the same translation set structure for developing the Media Translation module as the i18n module uses for taxonomies and menus. This gives Drupal website administrators and content managers a consistent approach to managing translated content.

One big challenge we faced while developing the Media Translation Display Override module was figuring out how to dynamically swap out the image or file based on the site language. During node load, we check if the attached file is in a translation set. If it is, we go through that translation set, find the right file for the site language, then copy the properties of the translated file to the node object before it is rendered by the theme layer.

One small hurdle we had to get over is how to get the Translation tab to show up in an Overlay on the media files. By default, it was showing up as a full page. We had to implement hook_admin_paths() to tell Drupal that the media translate tab can be displayed in the overlay.

Known Limitations

There are two known limitations with the Media Translation module:

  • Each media file can be in only one translation set.
  • When you select files for a translation set, you can select only from files for that language. For example, if you are selecting files for Italian, Drupal allows you to select only from files that have their language set to Italian.

Future Plans

We have no immediate plans to add additional functionality to our new Media Translation module. We welcome all feedback and suggestions for improvement.

In the meantime, give the Media Translation module a try, and see if it helps save you time managing your media files.

To install the module, go to http://www.drupal.org/project/media_translation.