Tuesday, March 24, 2009

Building a multi-language site with Drupal 6

Building a multi-language site with Drupal 6

Submitted by toma on Sun, 11/16/2008 - 15:28.
The following steps are for those who want to have a simple site available in deferent languages. The goal is to have content translated to two or more languages and the visitor to be able to choose any of them. Also, the menus must follow the selection. I have tested the result with content types page and story. I don't know what happens with forum, for example. I hope this helps you.

In the parentheses I give the relative path in the url. So, if your site is http://example.com/drupal and in parentheses I give admin/build/modules, then the url becomes: http://example.com/drupal/admin/build/modules

Install Internationalization module
Go to the modules (admin/build/modules) and in Core - optional section enable
Locale
Content translation
In the Multilanguage - i18n section enable all available. If you haven't enabled Poll and Profile modules, Drupal asks you if you want them enabled. If you don't want them, in the Multilanguage - i18n don't enable Multilanguage Poll and Multilanguage Profile.
Save
You now need the translation files for all the available languages of your site (if you haven't them already). Go to the translations page and download. Then extract them to Drupal's folder (see at 2 minutes 30 seconds into this videocast for the correct way to extract translations; you can ignore the rest of the video as it deals with installing Drupal in a language other than English, while this page deals with adding a language after Drupal has already been installed).

You have to add this language:

Go to the Languages page (admin/settings/language)
Add all the languages you downloaded and extracted (admin/settings/language/add)
Choose Configure
In the Language negotiation choose Path prefix only and save settings
Make sure English is the default language
Go to the blocks (admin/build/block)
In the Disabled area choose a Region for the Language switcher
Choose Save blocks
Ok, now you are at a good point. Choosing a language from the Language switcher, the Built-in interface changes to the corresponding language! If it doesn't make sure that it is translated. For that, navigate to admin/build/translate and check the ratio. It must be close to 100%.

The next steps are to make multilingual content.

Enable Multilingual support for all content types you want (admin/content/types)
Choose edit for the content type you want (e.g page)
In the Workflow settings choose Enabled, with translation and save
Now create content for the content type you have enabled multilingual support (e.g a page) (node/add/page)
In the Language field choose English
Save the page
Choose the Translate link
Choose add translation for the language you want
Write the page. The value in the Language field should show the selected language and be disabled/greyed out.
Save
Now you should be able to switch between translations when viewing the page by using the Language switcher block.

You might want to use flags instead, in which case you'll need the Language Icons module.

For your site to be fully translated you need to have the menus translated. You have two options!

Build a menu for every available language
Build one menu with links that point to every available language. What I mean is that if node/1 is your home page in English and node/2 in Greek, in your menu you have to make a link to node/1 named "Home Page" and one to node/2 named "Αρχική Σελίδα" (this is home page in Greek). You have to do this for every multilingual page.
Try both options and choose what is best for you.

1st option (multiple menus)

Add a new menu (admin/build/menu/add)
In the Menu name give a name, e.g. en-menu
Give title, description and Save
Add an item (admin/build/menu-customize/menu-en-menu/add)
Give the path for the English page (node/1)
Give the English name for the link
In the Language combo box you don't have to choose a language!
Save
Add a new menu for the second language (admin/build/menu/add)
In the Menu name give a name, e.g. el-menu
Add an item (admin/build/menu-customize/menu-el-menu/add)
Give the path (node/2), name and save
Use the same procedure to build menus for all the available languages you have
Ok, you now have your menus. Let's display them.

Go to the blocks (admin/build/block)
Go the the Disabled area and choose a Region for your menus
Choose Save blocks
For your English menu choose configure under Operations column
In the Multilingual settings choose English as language and save
Do the same for the rest menus and choose the appropriate language
2nd option (one menu)

Add a new menu (admin/build/menu/add)
In the Menu name give a name, e.g. multi-menu
Give title, description and Save
Add an item (admin/build/menu-customize/menu-multi-menu/add)
Give the path for the English page (node/1)
Give the English name for the link
In the Language combo box choose English
Save
Add another item (admin/build/menu-customize/menu-el-menu/add)
Give the path (node/2) and name
In the Language combo box choose your language, e.g. Greek
Save
Do the same if node/1 is translated to more languages
Use the same procedure to build menus links for all the available pages you have multilingual
Now, display your menu

Go to the blocks (admin/build/block)
Go the the Disabled area and choose a Region for your menu
Choose Save blocks
Done! Now, when you choose a language on the language switcher, you should see the content translated and the correct menu.

View the tutorial
Building a multi-language site with Drupal 6
Source Site Information
http://www.drupal.org

No comments: