drupal: setup for a multilingual site

28
  d r u p a l . o r g Setup for a multilingual site http://drupal-translation.com/

Upload: nelson-nunes

Post on 16-Jul-2015

159 views

Category:

Documents


0 download

DESCRIPTION

Setup for a multilingual siteOriginal document from drupal.org, i just create the pdf to be more accessible. --Ready to Print--

TRANSCRIPT

Page 1: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 1/28

 

 

d r u p a l . o r g

Setup for a multilingual site

http://drupal-translation.com/

Page 2: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 2/28

 

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 mainfeatures 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 andmanage 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 › 

Page 3: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 3/28

 

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} isyour 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

•  http://yourdomain.com/admin/build/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 Date Size Links Status

6.x-1.1 2009-Jun-22 116.08 KB Download · Release notes 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 enabletranslated content to be found more easily.

‹ Setup for a multilingual site up Setting up the languages › 

Page 4: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 4/28

 

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 › 

Page 5: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 5/28

 

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 thecontent 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 › 

Page 6: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 6/28

 

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 eitherwhen 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 › 

Page 7: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 7/28

 

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 acentral 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: 

Page 8: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 8/28

 

•  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 › 

Page 9: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 9/28

 

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 › 

Page 10: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 10/28

 

Setting the front page per language

When a user comes to your site via yourdomain.com you want to direct them to the front page. Whenthey come to your site via yourdomain.com/es 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 todo 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 urlto 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:

•  http://drupal-translation.com 

•  http://drupal-translation.com/es 

•  http://drupal-translation.com/de 

Page 11: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 11/28

 

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/drupal-6.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 thealias if the languages is showing "All".

‹ Adding the language switcher up Adding a menu › 

Page 12: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 12/28

 

Adding a menu

This page explains how to manually enter menu items and translate them using the Translate tab, createdby 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 menusfor other languages. This menu will link to each language home page and display correct text for theappropriate 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

Page 13: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 13/28

 

 

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 correcttranslation of "Home", "Inico" for our Spanish page in this example

Page 14: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 14/28

 

 

5) Resulting menu for the Spanish home page. 

Method 2: 

Using this method we create the menus from the administration pages.

1) Navigate to http://yourdomain.com/admin/build/menu-customize/primary-links and select

"Add item" 

2) Create a menu for the English home page. You need to set the Path, Title and make sure youset the Language to "English" 

Page 15: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 15/28

 

 

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

Page 16: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 16/28

 

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

Page 17: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 17/28

 

 

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 › 

Page 18: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 18/28

 

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 www.yourdomain.com and Spanish contentsin spanish.yourdomain.com.

Different languages can be in subdomains or completely different domains, including different top leveldomains (TLDs).

To do this, you'll need to setup Drupal to serve different languages in different domains and you'll alsoneed 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. 

Page 19: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 19/28

 

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

For English:

For Spanish:

Page 20: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 20/28

 

 

Setup in the server configuration file

Once you've set up Drupal to serve differnt languages in different domains, you need to instruct your webserver 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 www.yourdomain.com ServerAlias spanish.yourdomain.com 

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 › 

Page 21: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 21/28

 

Adding language icons

In Drupal, language flags can be easily included in the language switcher with the Language Icons modulehttp://drupal.org/project/languageicons.

Go to http://drupal.org/project/languageicons and download the module and install in yoursites/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 › 

Page 22: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 22/28

 

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 usestring 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 onlynodes 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 translationsof each other, but can also contain completely independent contents. Drupal and i18n don't offer anyfacilities 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 asstrings 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 bedisplayed otherwise it will display the original text.

To use this method set the block language to " All languages (Translatable)" while creating or editing ablock.

Page 23: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 23/28

 

NOTE: An important point when using this method is that the default language should be English. Drupallocalizes these strings with the t() function, meant to be called whenever a module outputs an English textstring.

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 blockdoesn't have to be displayed in order to be translated.

Page 24: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 24/28

 

Which now shows as:

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

Page 25: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 25/28

 

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.

Page 26: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 26/28

 

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 theirtranslation 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 translatedcontents as string translations. Users don't need to manually handle this as the module handleseverything automatically.

‹ Adding language icons up Drupal core translations › 

Page 27: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 27/28

 

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 administrationpages 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 updatedtranslations.

1. Locate the language file you need. You can use the 'Search' box at the right hand side of thetranslations 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 › 

Page 28: Drupal: Setup for a Multilingual Site

5/14/2018 Drupal: Setup for a Multilingual Site - slidepdf.com

http://slidepdf.com/reader/full/drupal-setup-for-a-multilingual-site 28/28

 

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 example.com/en, and the German nodeswith plain example.com. 

Edit the path prefix for each language. Go to admin/settings/language and edit each language. Set thepath prefix for English to en and the path prefix for German to "empty".

‹ Drupal core translations up