In my first post on Internationalization and Drupal we discussed, in detail, why translation is so important and how Drupal determines the correct language to use when serving content to the user.
This next post focus will be on configuring Drupal to use different languages, and then demonstrating how to translate content into the enabled languages.
After reading the first post in this series, you should be able understand what detection method is best for you and have already configured Drupal to use it. Now we need to configure what languages will be available for translation. To do so, go to /admin/config/regional/language and choose “Add language”, then select the language you want to use from the dropdown.
Drupal allows for you to define custom languages as well, if the language you want is not on the predefined list. There can be different variations between similar languages such as en-US and en-GB (US English and British English) for example, so if you’re not sure, familiarize yourself with the predefined language first. Example: https://localize.drupal.org/node/420
Now that we have the core translation modules enabled and configured we can begin translation. There are two types of translation that can be done at this point, String translation and Content translation.
String translation allows you to translate the User Interface of your website and any non content specific strings (views configuration, custom module strings etc). If you need the Drupal core content strings translated you can, in most cases, use the provided the core translation sets to quickly do so. In our French example we would download and import the Drupal core French.po file. (https://localize.drupal.org/translate/languages/fr)
For strings not included in the .po file, their is a custom string translation interface that allows us to define translations for any string in code. (Code that is properly wrapped in Drupal’s t() function). To do so go to admin/config/regional/translate/translate and search for the string you want to translate. Translatable strings are divided into text groups. You can search by string text or group. Choose edit on the string you want to translate and enter your translation in the form.
Content Translation provides the ability to translate nodes. Translation actually creates a copy of your current node and changes the language. You can translate all or some of the fields and the node will display in the language its assigned with the translation you added.
To begin content translation we need to enable our Content Types to allow translation. Edit the Content Type whose content you want to translate and choose the ‘Publishing Options’ tab at the bottom, then select ‘Enabled, with Translation’.
Once this is saved you will see a translate tab when viewing or editing any content of this type. Selecting that tab will allow you to add translations or edit existing ones.
There are many valuable contributed modules that provide additional functionality or different approaches to translating content in Drupal. Drupal core doesn’t provide for a complete translation of every aspect of Drupal site out of the box, but by using some these contributed modules we can cover pretty much all translation scenarios.
The Internationalization module extends the core translation functionality by adding tools to help with the translation workflow and adding translation capability to Blocks, Taxonomy and Menus. This is a must have module for a complete translation of your site. Internationalization has a *lot* of features and some of them can be confusing. Lets take a look at some of them.
- Field Translation
- Field translation allows you to translate field metadata like the Field Description and Help Text.
- Multilingual Content
- This adds additional configuration for Content Translation per content type.
- Ex: “Require language (Do not allow Language Neutral)."
- This adds additional configuration for Content Translation per content type.
- Path translation and Translation redirect.
- Provides Url Alias and Redirect functionality to translations.
- Variable Translation
- Allows you translate information that is stored in Drupal as a variable such as the ‘Site name’ and ‘Site Slogan’ values.
- Menu and Taxonomy Translation
- Allows translation of individual menus and a taxonomies, as well as display by language functionality. Needs to be configured per entity just like Content Types.
- Block Translation
- Allows per block translation of custom blocks.
The Entity Translation module allows us to take a different approach to content translation. Instead of creating a copy of the content as a new node and translating that new node, Entity Translation translates each field in a node(or entity) per language. The choice to use Entity Translation or Content Translation approaches is an important one, Entity (read field only translation) Translation does not support a lot of core features, like revisions and publishing control. However if all you really need is the actual text in your content to be translated for different users and nothing else, then Entity Translation could simplify your workflow.
There a number of other contributed translations modules, so many that we do not have the space to cover them all here. Instead we will turn to the problem of actually translating content and getting those translations into the system as painlessly as possible. At Mediacurrent we have worked on a number of highly visible translated sites including Redheart, Pega Systems, Manhattan Associates and IDT. One of the most surprisingly complicated issues is how to translate lots content efficiently once all of the tools are in place to do so. This can be done by having editors manually work through the UI; translating content and strings through the various interfaces by copy and pasting from translation documents. This is time consuming and difficult to manage when you have a large amount of pre-existing content to translate. Fortunately there are now a number of contributed modules to help with this problem. The standout workflow module is Translation Management Tool https://drupal.org/project/tmgmt.
Translation Management Tool provides improved workflows for managing the actual translations of content as well as allowing sites to plug into third party translation services. It also allows translations to be imported and exported via xliff(XML Localisation Interchange File Format) and HTML. By designating Translator roles and using the built in UI we can achieve an easier workflow for translating and approving translated content, as well utilizing third parties for large translation projects.
Another solution to managing your translation workflow would be to implement the LingoTek Translation module. LingoTek is a Mediacurrent partner that specializes in customizable translation workflows, translation services and are experts in Drupal translation.
As we have demonstrated, Drupal is capable of fully featured translation and can handle a number of different translation scenarios. Because of the flexibility and options available to actually implement translation, its important to carefully plan your translation strategy and to consider not only what type of content you’re translating (nodes, taxonomies etc), but how much needs to be translated and what the workflow needs of the translators are. Its very common to underestimate the amount of actual work required once the workflow is setup, because even with a robust workflow and trained editors, manual translations of content is very time consuming.
So translation is great in Drupal 7; what can we expect in Drupal 8? Internationalization was specified as one of the official Drupal 8 initiatives and will have a significant amount of improvements and integration with Drupal 8 core. See the initiative website for more info. http://www.drupal8multilingual.org/