Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Successful Multilingual Sites With Drupal 7

Successful Multilingual Sites With Drupal 7

Part 1

Given the appropriate environment, two languages are as normal as two lungs.

The decision to make your website multilingual may be driven by the desire to increase site traffic, increase sales, gain a better competitive edge, or as a courtesy for your customers. Whatever the reasons, a successful multilingual project requires a comprehensive and robust translation backbone.

Fortunately, Drupal 7 provides this necessary backbone. However, if you’ve not done this before then there is a bit of a learning curve to go through. There is also the situation that there are multiple ways of translating content and you might need to decide between them.

In an effort to flatten this curve, I offer this blog post which is written in the light of my recent experiences in creating a tri-lingual system.

Localisation

Localisation is concerned with the characteristics of the site that serve to define its local environment. 

1.       Setup basic localisation.

Drupal core provides the basis of localisation at Administration > Configuration > Regional and language. Here you can set the default country for the site as well as the default time-zone.

2.       Install required languages.

Additional settings are maintained through the Locale module, which also allows you to present your Drupal site in a language other than the default (English). Note that the module allows you to translate the site interface not the content. You need additional modules for that.

Locale allows you to select from any of the 80 or so languages that are supported by the Drupal translation communities. You can install and manage supported languages at admin/config/regional/language/configure.

Installing a language is facilitated through gettext using portable objects files which contain source strings and their translations. Once installed, you will be able to display your site’s UI in the new language, registered users may select their preferred language, and authors can assign a specific language to content.

3.       Set how the site selects the language for display.

You can select the logic used to determine which language is shown to the user using the detection and selection tab. For example you can set the language according to the url pattern used to display the page. A typical example is that French pages will be displayed whenever the path is prefixed by fr.

4.       Enable the language switcher block.

The locale module generates a block containing the necessary code to display a link, which can be used to select the desired language. Note that there are contributed modules that provide additional functionality here. For example, the Language Icons module that provides icons for language links.

Part 2 – Translation

Now that you have the UI translations successfully configured it is time to think about your site’s content. This is where the multiple options mentioned earlier come into play.

Option 1 – Content translation module

Earlier versions of Drupal created a complete copy of each node that needed translation. So a French node would have all the French values of the content and the English node would have all the English values. They are organized together in translation sets, so Drupal knows which are the 'same' content.

Option 2 – Entity translation module

There is an alternative where each piece of content consists of a single node, but each field on the node can have multiple copies, in different languages, all attached to the same entity.

Additionally, Drupal’s modular architecture allows you to “mix and match” these options by having one option for one set of content types and the other option for another set.

How to choose?

 The strategy you choose depends on the functionality and design of your site. Our partners at Acquia have provided a handy table to help make a decision.

Content translation

Entity translation

Only works on nodes

Works on all entities

One node per language

One entity for all languages

Uses core node title field

Requires title module

Views language filtering works

Required a patch to filter on entity language

 XML Sitemap works

XML Sitemap could not filter on entity language

Block translation is difficult (apart from title)

Bean block module

Multiple menu items per language

Single menu item per language

For my project we chose Content translation because the user wanted different versions of the node for each language. So the rest of this post is about that option.

 5.       Enable the Content Translation module.

The Content Translation module enables you to select a language for each node on your site.

6.       Configure content types to support translation.

You have to set each and every content type that you want to translate to support translations. This is done at Administration > Structure > Content Types. Edit the required content type and set the Publishing options for Multilingual support to enabled with translation. Now when creating content you can set its language. Translations are associated with each other enabling the system to display the correct translation depending on the current site language.

This is enough to get the basics of localisation and translation working but it’s only part of the story. In addition to this we had to make use of the Internationalisation module to provide additional functionality, such as translating variables and views. That’s a subject for another blog post.

In the meantime Drupal’s own guide to multilingual site production is at a good read.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web