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.
Why the Media Translation Module is Useful
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:
- Upload the USA version of an image file.
- Next, upload the files for the other languages, such as the Spanish and Italian versions.
- 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.
- Edit one of the image files and click the Translate tab.
- Associate the related image files. This is called a translation set.
- 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.
- Enable the module Media Translation (under the Media section).
- Go to the Configuration menu, and in the Media section, select File Types.
- For each media file type that will support translations (e.g., images), click manage fields.
- Click on the Translate tab.
- Select the Translate mode to Translate.
- Click Save.
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.
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.
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.