Set up Drupal 7 for multiple languages

The following tutorial should help me remember the structure of this blog and hopefully helps other people setting up their own Drupal environment. Setting up Drupal with internationalization was relatively quick, but not everything I created was translatable right from the start. Especially lists of links weren't shown in the selected language or their headings couldn't be translated.

The solution to this problem is the usage of Views and a module to translate Views themselves. But let's start from the beginning:

Installing Drupal

This shouldn't be very hard as long as you read and use the installation guide from drupal.org. To recap the steps, that is:

  1. Downloading Drupal
  2. Extract archive
  3. Upload extracted archive to your server
  4. You can use the script /install.php to make the next few steps easier to understand and to conduct
    1. Create a database and a database user for Drupal
    2. Create /sites/default/settings.php with the relevant database information (by copying /sites/default/default.settings.php)
    3. Install by using the script (/install.php)

All of these steps are explained in the said installation guide in great detail. I would recommend the standard installation profile for Drupal-Newbies, since you need many of the modules later and many of the options are not present in the administration user interface without them. The stupid thing about it is, that many tutorials you find online rely on them.

Installation of needed modules

Fortunately, the installation of modules is not a big deal. Usually, you download and extract the module right into your servers directory in /sites/all/modules/. Modules you need for this site are:

After having all modules inside the /sites/all/modules/ directory, you can activate them via the administration interface in Administration -> Modules.

Actually, you don't really need the Views module for a basic Drupal-powered site, so ctools, views and i18nviews are more or less optional. But my experience is, that you usually need more than the basic modules of Drupal. Without writing own code or install other modules, you will find the limits of Drupals functionalities rather quickly. Using views, you can put up links to different categories easily as you can see here in the Latest Entries Block. To have these views behave differently in different languages, you will definitely need the i18nviews module.

Usage of translation options

To actually have your site in multiple languages, you need to set up some prerequisites. First, you have to inform Drupal about all languages you want to use. Second, you have to translate every single content on your site - every little string. Of course there is localization available for the administration interface and everything around the core Drupal, but all content and block titles have to be translated. To understand what a block, article, page or, more generally, content is for Drupal, have a look into the structure guide of the Drupal documentation. If you don't know yet what a Node in the context of Drupal is, you should have a look at it first.

Setup the different languages

Before you are able to translate content of your site, you need to inform Drupal about the languages you are going to use. In the administration menu, you can find this option in Administration -> Configuration -> Regional and language.

Translating content

There are multiple ways to start translating content. In the administration interface, while working on a page or an article, you can find a Translate Tab on the top right using the default theme. Another possibility is to look at the article or page itself on your site and click on the Translate Tab as long as you are logged in and have the needed rights to do that.

A translation itself just creates a new node, but it is linking this node with the translated one. This way you always get the right article or page in the selected language. If there isn't a translation for the selected language (yet), a Page not found error message will appear.

Translation is also possible for variables, what you can do in the administration interface. A multilingual variable always yields this information and at the top of the page you can then find a language selector, to change the variable for a different languages.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd><h2> <h3> <h4> <h5> <h6>
  • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or class="OPTIONS" [title="the title"].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.