You are on page 1of 28



Setup for a multilingual site

Setup for a multilingual site

Drupal 6 has multilingual support to allow you to create multilingual websites with ease. The i18n module adds to ability to create and manage multilingual contents and to display it. The main features it adds are: Translate node contents Allow translating strings such as taxonomy terms Group elements together to provide unique content per language Provide language selection, which visitors can click on Let site admins enter contents in multuple languages

We'll cover how to set up a Drupal site to hold contents in multiple languages, how to create and manage multilingual contents and how to let visitors choose the display language. Installing the required modules Setting up the languages Enabling Multilingual support for Content Preparing content for translation Creating translations Adding the language switcher Setting the front page per language Adding a menu Using a different domain name for each language Adding language icons Block content translation Drupal core translations Common questions

Installing the required modules

Installing the required modules

The i18n module will allow your site to easily display content in multiple languages. Extract the downloaded archive into ${DRUPAL_HOME}/sites/all/modules/ where ${DRUPAL_HOME} is your root of your Drupal 6 installation. After extracting the module, a new directory will be created: ${DRUPAL_HOME}/sites/all/modules/i18n

Enable the multi-language modules Administer > Site Building > Modules Enable all the modules under "Multilanguage" and save the configuration. *

* Note: This site has been updated to the 6.x.1.1 release of i18n. i18n version used in this tutorial: Official releases 6.x-1.1 Date 2009-Jun-22 Size 116.08 KB Links Download Release notes Status Recommended for 6.x

Additional modules: You may also want to enable the path module at this point if it's not already enabled. This will enable translated content to be found more easily.

Setup for a multilingual site up Setting up the languages

Setting up the languages

In order for the site to include contents in multiple languages, these languages must first be added. Navigate to /admin/settings/language and select "Add language". Add all the desired languages.

Note the warning about setting the default language. It is important that you decide this early. See the note in the discussion about translating user defined strings (at the bottom of the page). Once you've added all the languages go to Configure and select the desire language negotiation settings. If you are not sure try "Path Prefix Only". This will allow the language to be selected by a prefix in the url. Example: "/de/contact" sets presentation language to German based on the use of "de" within the path.

Installing the required modules up Enabling Multilingual support for Content

Enabling Multilingual support for Content

In this step, we'll select which types of content need to be translated. Navigate to /admin/content/types and select a content type that you will want translated. Under "Workflow settings" select Multilingual support - Enabled, with translation. This will add a "Translate" tab to the content page, we will see this later. Repeat for all content types that you will want translated. What you will see when Multilingual support is enabled.

Setting up the languages up Preparing content for translation

Preparing content for translation

Setting the source language For content to be translated you must select the language that the content is in. This can be done either when entering new content or editing content.

If the "Translate" tab is not available for your content then the language for the content is probably set to "Language neutral".

Enabling Multilingual support for Content up Creating translations

Creating translations
This page explains how to manually enter translation using the Translate tab, created by the i18n module. If you're also using the ICanLocalize Translator module, content translation can be managed using a central Translation Dashboard and done by professional translators. Select the page you wish to translate and then select the "Translate" tab. Select add translation:

Now enter your translation:

Select save to save the translation.

The translation has been saved and it now includes a link back to the source document.

Preparing content for translation up Adding the language switcher

Adding the language switcher

Navigate to /admin/build/block and add the language switcher to the left sidebar.

Block settings

Language selector now in left sidebar.

Creating translations up Setting the front page per language

Setting the front page per language

When a user comes to your site via you want to direct them to the front page. When they come to your site via you want to direct them to the Spanish front page. In order to do this, you need to set the path to the home page node. That path must be the same for all language versions of the home page. Then, go to the Site information admin page and set that path as the Default front page. Here is how to do this, step by step. 1) Edit the node for your home page and set the path url - example: try setting it to "home"

2) Do the same on the Spanish node that you want to be your home page and set the path url to the same value, "home" in this example.

3) Go to your Site information page /admin/settings/site-information and set the front page to the same as the URL path - "home" in this example.

4) Save the configuration and test your urls.

You can see it in action on this site:

Update: You may get the following warning: user warning: Duplicate entry 'home-es' for key 2 query: UPDATE url_alias SET src = 'node/126', dst = 'home', language = 'es' WHERE dst = 'home' in /home/bruce/drupal/drupal6.13/modules/path/path.module on line 108. This appears to occur if you have already used the alias before but on a language neutral page. You can try editing the url aliases directly at /admin/build/path. Search for your alias name and delete the alias if the languages is showing "All".

Adding the language switcher up Adding a menu

Adding a menu
This page explains how to manually enter menu items and translate them using the Translate tab, created by the i18n module. If you're also using the ICanLocalize Translator module, menu items will also be translated along with the node contents. We will now add a menu item to the Primary links for the default language and create translated menus for other languages. This menu will link to each language home page and display correct text for the appropriate language. There are 2 ways of doing this: 1) Edit the page and add a menu or 2) Add menus via the administration pages.

Method 1:

1) Select your home page and select "Edit" and click on "Menu settings" if they are not shown

2) Enter a name for the menu, "Home" in this case

3) Save the page. We have now created a "Home" page menu.

4) Repeat the steps for the translated home page and change the menu link title to the correct translation of "Home", "Inico" for our Spanish page in this example

5) Resulting menu for the Spanish home page.

Method 2: Using this method we create the menus from the administration pages. 1) Navigate to and select "Add item" 2) Create a menu for the English home page. You need to set the Path, Title and make sure you set the Language to "English"

3) Repeat for the spanish home page and set the path to the Spanish home page, the title in Spanish and set the language to "Spanish".

4) This should now give the same results as method 1.

NOTE: On some administration pages both menus are shown.

This is by design and only the menus for the current language will be displayed for normal users.

Setting the front page per language up Using a different domain name for each language

Using a different domain name for each language

Drupal makes it easy to serve different language versions of your websites from different domains. This allows you, for example, to have English contents in and Spanish contents in Different languages can be in subdomains or completely different domains, including different top level domains (TLDs). To do this, you'll need to setup Drupal to serve different languages in different domains and you'll also need to setup your web server to point all domains to the same Drupal site.

Setup in Drupal
1) Go to /admin/settings/language/configure and select "Domain name only" as the Language negotiation.

2) Go to the language administration page, /admin/settings/language and edit each language to include the domain name For English:

For Spanish:

Setup in the server configuration file

Once you've set up Drupal to serve differnt languages in different domains, you need to instruct your web server to send requests from multiple domains to the same Drupal site. In Apache, you'll need to edit the .conf file and add aliases to all the different domains. For example: ServerName ServerAlias In addition to this, you'll also need to point the domain name server (DNS) to your server for all the domain names in different languages.

Adding a menu up Adding language icons

Adding language icons

In Drupal, language flags can be easily included in the language switcher with the Language Icons module

Go to and download the module and install in your sites/all/modules directory. Navigate to the module admisistration page in your website, /admin/build/modules, and enable the "Language Icons" module listed under the "Multilanguage" section. Then save the configuration and that's it, you should now have flags in your language switcher.

Using a different domain name for each language up Block content translation

Block content translation

Drupal's i18n module can translate block contents.
To display blocks in multiple languages, you can use one of these approaches: 1. Creating a different block for each language. 2. Using string localization When you create a block, you can choose to assign it to a specific language or to all languages and use string translation.

Method 1 - different blocks per language

Select a unique language for the block and indicate which nodes to display it for. You should select only nodes that are written in the same language as the block. Then, create similar blocks in other languages and enable them for the nodes in those languages. This process will keep complete isolation between blocks in different languages. They can be translations of each other, but can also contain completely independent contents. Drupal and i18n don't offer any facilities for synchronizing between block contents in different languages.

Method 2 - string localization

Drupal can translate strings from English to other languages (currently, there is no solution for translating from any language other than English). You can tell Drupal to handle the title and contents of blocks as strings and look for translations using Drupal's string translation mechanism. When a block is being displayed in a different language, Drupal will look up the title and body of the block to see if there is a string translation of the title and body. If they are available the translation will be displayed otherwise it will display the original text. To use this method set the block language to "All languages (Translatable)" while creating or editing a block.

NOTE: An important point when using this method is that the default language should be English. Drupal localizes these strings with the t() function, meant to be called whenever a module outputs an English text string. Here is an example. We'll create a new block and translate its strings.

Create the block and set to 'All languages (Translatable)'

Choose where the block is displayed We'll display this block in the right sidebar. The display position doesn't really matter and the block doesn't have to be displayed in order to be translated.

Which now shows as:

Switching to Spanish shows the block visible but with no translation:

Manually entering translation for the block contents The strings for the title and the body are translated using the translate interface. Go to /admin/build/translate/search and look for the strings used in the block.

Click on "Edit" and enter the translation.

Repeat for the body of the block searching for some text in the body. This should now give you a fully translated block on the Spanish home page.

Translating blocks using ICanLocalize Translator ICanLocalize Translator handles block translation using Drupal's string translation mechanism. Although internally nodes and blocks are constructed differently, ICanLocalize Translator makes their translation appear the same. Blocks will appear in the translation dashboard just like all other content types. Behind the scenes, ICanLocalize Translator will fetch the strings created by the Drupal blocks and return the translated contents as string translations. Users don't need to manually handle this as the module handles everything automatically.

Adding language icons up Drupal core translations

Drupal core translations

Drupal has been translated to many languages. You can download them from Drupal's translations portal. These are translations for Drupal itself (not your contents). Using them will convert the administration pages to other languages. Here are some popular language packs: * * * * * * * Spanish German Russian Italian Dutch Chinese, Simplified Korean

Instructions for adding new translations Download and install the Localization Client module. This is required for importing new or updated translations. 1. Locate the language file you need. You can use the 'Search' box at the right hand side of the translations page. 2. Download the language pack for your version of Drupal to your Drupal root directory. 3. Extract the content of the zipped file. 4. Go to the translate interface at admin/build/translate, select "Import" and then "Reimport packages". To do this step the Localization Client module needs to be installed and activated.

Block content translation up Common questions

Common questions
How do I remove the link to the other translation at the bottom of my page ?
You can do this from the Multilingual setup page: admin/settings/language/i18n Select "Hide content translation links".

I started a site with English as the default. How do I change it to German?

What I would like to do is to have English nodes come up with, and the German nodes with plain Edit the path prefix for each language. Go to admin/settings/language and edit each language. Set the path prefix for English to en and the path prefix for German to "empty".

Drupal core translations up