One of the best things about Drupal is its robust multilingual support. If you need to build a website that supports multiple languages, Drupal should definitely be an option to consider.
Required modules
- Locale (core module)
- Content translation (core module)
- Internationalization
- Variable (dependency for Internationalization)
Making your site multi-lingual
- Install and enable the required modules.
drush en i18n i18n_node -y
This will enable i18n and its dependencies. The i18n module comes with a number of sub-modules, which you can enable based on your requirements. For now, just enable
i18n_node
for content translation. Go here for a comprehensive write-up of all the sub-modules. -
Go to
admin/config/regional/language
and add the languages you want to support. You can select from a list of predefined languages as well as add your own custom language. -
You can add as many languages as you need to support, and manage them from the Languages admin interface.
-
There are several options for accessing each of the translated versions of the site. The most common method is via URL, either by domain or by path prefix, and Drupal 7, out-of-the-box, supports both these options.
Translating content
-
If you started out on a brand new site with no content, then this issue won’t apply to you, but if your site already had content before you turned on multi-lingual support, you may see your existing content being assigned as Language neutral.
-
Every content type, by default, has multilingual support turned off. Changing this to Enabled will give you the option to set the default language for a particular piece of content, while changing it to Enabled, with translation will add a Translate tab when you’re editing that piece of content.
-
The Translate tab shows all the translations of a particular piece of content. Each translation is a separate node, but they are all recognised as translations of the source content by a
tnid
in the database.
Translating other parts of the site
There’s a lot more content that requires translation other than just plain content from nodes, from menus, to taxonomy terms to views and that’s the reason there are so many sub-modules for the i18n module. The translation functionality has been modularised in this manner for ease of customisation.
Translation is always tricky to implement, and there are certain gotchas that may trip you up, especially if your site is more complicated. Trust me, I’ve been there so I wrote up a couple of translation gotchas from a previous project.
Menu translation
Activating this sub-module will turn on Translation sets as well, and you will see additional Translate tabs and Multilingual options interfaces when you edit your menus.
Setting your menus to Translate and localise let’s you translate the menu links and they will appear in their respective languages specified, if a translation was provided.
Taxonomy translation
Turning this sub-module on allows you to provide translations for your taxonomy terms. The difference between localise and translate is that localisation uses the same taxonomy ID across languages while translating creates a new taxonomy term altogether.
Views translation
Views is an indispensable module for many sites and it is possible to translate every part of your content created from views. It is also possible to filter your views content based on language so if a particular piece of content does not have a corresponding translation, it will not show up in the view.
The translate views interface lets you translate elements that are generated by views like buttons, links and custom content entered into the views header or footer.
String translation
This sub-module allows you to translate user-defined strings. Depending on which other sub-modules are enabled (e.g. menu or panels or views), different sets of texts are made available to be translated.
You will be able to see the original string, and enter an appropriate translation to that string.
Wrapping up
This post has merely skimmed the surface of building a multi-lingual site with Drupal, and if your project requires a multi-lingual implementation, Drupal is definitely an option worth considering. It may not be perfect, but it does the job reasonably well compared to its competition.