Using Drupal Chapter 8: Multilingual Sites

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Alternate resources

In this series, based on the O'Reilly book Using Drupal, 2nd Ed., you'll learn how to use Drupal core's multilingual features, along with the Internationalization suite of modules, when building a multilingual site.

See our guide Using Drupal Book by O'Reilly Media to access all of our tutorials related to this book. Each series covers a chapter (or appendix).

Tutorials in this course
More information
Creating a website with community content is great, but what if some or all of your community doesn’t read or write English? It’s a big world, and only about 6% of it speaks English as a native language. Having multiple languages is not as simple as having users post content in whichever language they like. There are other things to consider, like navigation, date formatting, and help text. And what about having the same post available in multiple languages, and easily navigating between them? Once you start thinking about it in detail, there is a lot of ground to cover. Luckily, Drupal core and a few contributed modules have done a lot of that hard work for us so we can concentrate on building our community and content. In this series, we'll cover the two main concepts for multilingual sites: internationalization, often abbreviated i18n, and localization, often abbreviated l10n. Internationalization is the underlying structure that allows software to be adapted to different languages, and localization is the process of actually translating the software for use by a specific locale.
 
In this first lesson we'll kick things off with an overview of our case study with Blue Peak Fanatics, take a look at the site we're going to build, and discuss how we'll go about implementing the features we need.

Additional resources

Using Drupal, 2nd edition Using Drupal source code

More information

There are two main areas of translation for your Drupal site: the user interface and the content. The user interface text is mostly provided by the software, stored in the code itself. This is sometimes referred to as "hard-coded." While content is generated by users of the site, and stored in the database. Drupal core comes with the Locale module, which works with the user interface text and gives you a nice set of tools that lets you import existing translations, create or edit your own, or export your site’s translations for use on other sites. In this lesson we'll take a tour of the Locale module and discuss translation files, translating strings, language switching, and how to get a localized installation.

Additional resources

Using Drupal, 2nd edition Using Drupal source code

More information

The first step to using any of Drupal’s multilingual features is installing a translation, so that Drupal has more than one language to choose from. As mentioned previously, you can use a localized distribution so that you install your language during the site installation process. Alternatively, you can easily add a language after you have installed the site by using the “Localization update” module. In this lesson we'll get the right pieces in place and get two different languages installed on the site.

Additional resources

Drupal Translations on localize.drupal.org
Using Drupal, 2nd edition
Using Drupal source code

More information

With several language translations installed on our site, we need to make a choice about how and when Drupal will use our new languages. In this lesson, we'll review the Locale module configuration to make sure it is performing the way we want it to, by setting language detection and selection, and then enabling our language switcher.

Additional resources

Using Drupal, 2nd edition Using Drupal source code

More information

You may notice that even though you are using a translation that you have installed, there might still be some untranslated text peeking out here and there. This will become more likely as you add contributed modules. Almost no site will have absolutely 100% language coverage out of the box, so you will probably need to translate a few items yourself. Drupal has a built-in system to do this with the Locale module, but there is also a contributed “Localization client” module which extends this core feature. In this lesson we'll take a look at Localization Client, see why want to use it, and how it works.

Additional resources

Localization Client project
Using Drupal, 2nd edition
Using Drupal source code

More information

Not everyone wants or needs to install yet another module, and due to the caveats we mentioned about Localization client, it is still a good idea to be familiar with all of your options. In this lesson, we'll review the Locale module translation process, then enable Localization Client and start translating some text!

Additional resources

Localization Client project
Using Drupal, 2nd edition
Using Drupal source code

More information

When it comes to translating your site’s content in Drupal 7, we have two possibilities. There is the core “Content translation” module and the contributed “Entity translation” module. They have quite different approaches to translation. So, in this lesson we'll compare the Content and Entity Translation modules, and take a look at how node translations work.

Additional resources

Video about the difference between Content and Entity
Using Drupal, 2nd edition
Using Drupal source code

More information

With our interface taken care of, now we can configure multilingual support for our content. That is, we need to be able to identify which language a given piece of content is written in and then create translations. So, we already have articles, and we need to add a knowledge base to the site as well. For both of these types of content, we’ll need to identify the language they are written in, as well as provide related, linked translated versions. In this lesson we'll enable the core Book module for our knowledge base, enable multilingual content, and start translating our knowledge base.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

More information

So far we’ve got a nice start with getting our site translated, but everything is not quite smooth yet. We have translations for some of our content and menu items, but we're seeing all the content at the same time. You will also see some stray interface text still in English. To take our multilingual site further and really make it shine, in this lesson we're going to turn to a package of modules called Internationalization (i18n). There is a central Internationalization module, which comes packaged with a handful of other modules designed to work together to extend core’s multilingual features.

Additional resources

Internationalization (i18n) project
Using Drupal, 2nd edition
Using Drupal source code

More information

Translated content on a Drupal is all shown at the same time by default. The Internationalization module will let you display only content that is relevant to the language currently in use, which is referred to as "content selection." In this lesson we're going to configure our site's content selection and the test it out to make sure it working as expected.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

More information

Before we can translate the various site-wide variables, like the site name or slogan, we need to let Drupal know which ones we want to make translatable. To do this, we’ll need to use the Variable translation module from the Internationalization package. In this lesson we'll enable a multilingual variable so that we can see how to translate the site name.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

More information

We’ve translated the site name, but we still have other stubborn text on the site that we couldn't select on the Variable translation page. Our content types for the site are still using English for the content type name on the “Create content” page, and for field names when making new content. In this lesson, to fix this up, we'll walk through translating content type names, the Title label on the content type, and also see how to tackle the field labels as well.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

Categories
Drupal 7
More information

When using Drupal’s taxonomy system, we need to find a way to sync the terms that we create to keep the taxonomy selection limited to just the terms for a given language. We don’t want all of the different languages showing up at the same time when someone is looking at a vocabulary or individual terms on the site. We're going to work with taxonomy to create our site's forum. The Forum module’s containers and forums structure is built on Drupal’s core taxonomy, so it is also creating a new vocabulary on our site. The forums on our client’s site need to display the threads that follow the same content selection rule as the rest of the content on the site. That is, we’ll only show the forum posts for the selected language. The site will have preset containers and forums, and then users may post to them using whichever language they choose.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

More information

The last little thing we need to do to clean up our site is to get our Home tab in the Main menu translated as well. Everything else in the menu is now translated, but the Home menu item isn't from one of the other features we've created. It's just a regular menu item. In this lesson we'll enable multilingual menus and get that home page tab translated.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

More information

There are a lot of tools available for working with multilingual sites, and we've implemented the main pieces we needed to build the site that Blue Peak Fanatics needs. In this lesson we'll take a look at some more modules we might consider down the road.

  • Language icons
  • Language switcher dropdown
  • Transliteration
  • Translation overview
  • Translation table

Additional resources

Using Drupal, 2nd edition
Using Drupal source code

More information

We built a nice, simple, easy-to-use site for our clients that gave them the tools they needed for discussions and a knowledge base. We set up a forum that displays only posts that are in the user’s language and a knowledge base book where all of the site members can create translations for the pages. The major need for this community was being able to use multiple languages and easily extend those languages in the future. Using Drupal’s core internationalization features with a handful of contributed modules, we have given them a very flexible multilingual solution. In this final lesson we'll tour the Blue Peak Fanatics site, discuss our implementation points, and review the modules and resources we used to build this site.

Additional resources

Using Drupal, 2nd edition
Using Drupal source code
Up next: Using Drupal Chapter 9: Online Store

This course appears in the following guides:
Site Building
Drupal 7 tutorials related to the Using Drupal book, 2nd edition, published by O'Reilly Media

Using Drupal Book by O'Reilly Media