Sunday, July 05, 2009

build multiple languges site with drupal


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 pageand 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 ishttp://example.com/drupal and in parentheses I give admin/build/modules, then the url becomes: http://example.com/drupal/admin/build/modules

  1. Install Internationalization module
  2. Go to the modules (admin/build/modules) and in Core - optionalsection enable
    • Locale
    • Content translation
  3. 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.
  4. 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 thisvideocast 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:

  1. 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
  2. Make sure English is the default language
  3. Go to the blocks (admin/build/block)
  4. In the Disabled area choose a Region for the Language switcher
  5. 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.

  1. 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
  2. Now create content for the content type you have enabled multilingual support (e.g a page) (node/add/page)
  3. In the Language field choose English
  4. Save the page
  5. Choose the Translate link
  6. Choose add translation for the language you want
  7. Write the page. The value in the Language field should show the selected language and be disabled/greyed out.
  8. 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!

  1. Build a menu for every available language
  2. 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)

  1. Add a new menu (admin/build/menu/add)
  2. In the Menu name give a name, e.g. en-menu
  3. Give title, description and Save
  4. Add an item (admin/build/menu-customize/menu-en-menu/add)
  5. Give the path for the English page (node/1)
  6. Give the English name for the link
  7. In the Language combo box you don't have to choose a language!
  8. Save
  9. Add a new menu for the second language (admin/build/menu/add)
  10. In the Menu name give a name, e.g. el-menu
  11. Add an item (admin/build/menu-customize/menu-el-menu/add)
  12. Give the path (node/2), name and save
  13. Use the same procedure to build menus for all the available languages you have

Ok, you now have your menus. Let's display them.

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

2nd option (one menu)

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

Now, display your menu

  1. Go to the blocks (admin/build/block)
  2. Go the the Disabled area and choose a Region for your menu
  3. Choose Save blocks

Done! Now, when you choose a language on the language switcher, you should see the content translated and the correct menu.

No comments: