How to setup a multilingual website with Drupal 7
Setting up a basic Drupal website in English is relatively easy. Setting up a multilingual website isn't as obvious as you would hope it to be. Knowing a thing or two about how and where to find help on drupal.org is a must. See References for more information.
The present article does not address the topic of multilingual menus.
Alright, let's do it.
- Starting with a fresh Drupal 7 install is the best way to avoid problems. That said, it is possible to transform a unilingual website into a multilingual one. Let's just say that it is beyond the scope of the current article.
- Activate the Locale and Content translation modules. Both come installed with Drupal 7.
- Download, install and activate the i18n and Variable modules (and all their submodules). The Variable module is new and required by i18n in D7. It provides a simple interface where you can designate system variables as Multilingual variables. In D6, you have to do it by hand in the settings.php file (See References block). More on the usefulness of the Variable module a little later.
- Go to the languages interface (
admin/config/regional/language) and add a new language to the list. In this article, I'll be adding French. - Now, add a Path prefix language code to each language. You can do this by clicking the language edit link (
admin/config/regional/language/edit/en). In the current example, I've added "en" for English and "fr" for French. Note the warning: Modifying this value may break existing [node] URLs. I had created a couple of nodes prior to making this change and encountered many nagging problems related to bad links. Deleting and recreating all existing nodes solved all those problems. If you have many existing nodes, export them before deleting them. Then import them back. You can do this more easily with the Node export module (http://drupal.org/project/node_export). Also, make sure the option "Determine the language from the URL (Path prefix or domain)" is enabled atadmin/config/regional/language/configure. - Once this is done, go to the Drupal translation page (http://localize.drupal.org/) and download the translation package for the language you just added. In this article, French for Drupal core 7.x. Look for the Download link which appears to the right of Drupal core 7.x. If you hover over this link, you will see that is points to a file named drupal-7.x.fr.po. Download this file to your desktop.
- Go to
admin/config/regional/translateand click on the Import tab. Import the translation package you've just downloaded into the desired language (drupal-7.x.fr.po into French for this article). You may need to import other project (module) packages (e.g. Views, Panels, etc.). But you can do that later. - Go back to the Overview tab. Note the higher percentage for translated strings for the language you added.
- Next, we will activate the Language switcher block which will allow users to switch between languages. Go to
admin/structure/block. Look for Language switcher and set the region (sidebar first in the present case). Click the Save blocks button at the bottom of the page. Goto your Home page and check that the block is showing. Clicking the different languages will switch the interface back and forth between them. - The last step is to enable Multilingual support, with translation for each of the content type that you require. For the Article content type, go to
admin/structure/types/manage/articleand click on the Publishing options tab (the horizontal ones) and activate the Enabled, with translation radio button. Then click the Save content type button. Repeat for all content type that need a language specific translation.
That's it. Your website is multilingual ready. Now every time you create a new node (Article, Page, etc.), you'll have to specify which language it belongs to. Language neutral nodes will be displayed just the same for all languages. That's why this article appears in English as well as in French. Check it out.
Cheers!
p.s. I'm thinking screen captures would be nice, right? I'm also thinking about a screencast version. That would be cool...
Comments
Neil (not verified)
Fri, 08/05/2011 - 16:44
Permalink
Not quite what I expected.
Ok so I followed these instructions religiously and I get a new tab i.e. View | Edit | Track | TRANSLATE. I get the other language link (in my case Francais) display at the end of the article which when clicked on did toggle between the translations the first time but no longer. I get the ability to position the Language Switcher in Blocks but it doesn't show in either admin or user.
To be honest I was hoping that I would simply get English and French radio buttons and a module would do the translation for me (as in Google Translate)
BTW. Perhaps Step 7 needs a little more explanation as the it is presented as page not a downloaded file and in Step 4 I believe you want to go to simply Configuration/Language.
Regards, Neil
admin
Fri, 08/05/2011 - 18:30
Permalink
There's a lot more to Drupal than meets the eye...
Hello Neil,
If toggling between the source and its translation doesn't work, try deleting the translation and recreating it & keep a close eye on the paths. As for the Language Switcher block not showing somewhere or for someone, have a look at its Visibility settings (blocks admin page, under Configure) and make sure there are no restrictions.
I've revisited step 7 and added explanations. Let me know if it is still unclear. I'll also add more links in References block (top-right).
Cheers!
guest (not verified)
Sat, 09/03/2011 - 10:33
Permalink
invisible language switcher block
Hi,
i also had the problem with the invisible language switcher block. What helped me was to enable the URL detection method under administration > configuration > regional and languages > languages > detection and selection.
hope this heps
cheers
admin
Sat, 09/03/2011 - 11:12
Permalink
Good point!
I've updated step 5 to reflect this.
Boyan (not verified)
Fri, 09/16/2011 - 04:31
Permalink
Set multilingual homepage
Thanks for the great guide!
I've done this and everything is right, except that I have problems with setting my custom homepage to be multilingual. After I set in /admin/config/system/site-information the "Default front page" URL slug to be the one I want (which has the same URL slug for all three languages, just the language prefix differs), Drupal automatically chooses the "node"-type of this page's URL slug and thus I have just one language version of the homepage in all three languages.
Am I clear enough and can you help me here?
Boyan (not verified)
Fri, 09/16/2011 - 04:40
Permalink
Set multilingual homepage - 2
To make myself more clear: I have a page in three languages with the URL slugs as follows:
homepage.html (default bg language)
en/homepage.html
de/homepage.html
Then I want to make this my homepage, go to /admin/config/system/site-information and enter "Default front page" URL slug to be "homepage.html" . But, when I switch to the other 2 languages, the homepage language version doesn't change and in /admin/config/system/site-information I see that drupal has chosen the "node"-type of the URL slug for the other 2 languages
I'll be helpful if you know where is the problem.
Boyan (not verified)
Fri, 09/16/2011 - 16:05
Permalink
Set multilingual homepage - Solved
I actually created multilingual homepage via views, sorry for bothering...
andy (not verified)
Wed, 11/02/2011 - 12:04
Permalink
Thanks
A very good, easy to follow set up. Helped a lot to get me started.
Thanks
Sucheta (not verified)
Wed, 12/14/2011 - 02:24
Permalink
Can we select other options provided for step 5
As per your step 5, you have selected "Path prefix language code". Can we select "Determine the language from a request/session parameter" or "Follow the user's language preference" option to avoid the breaking of URL throughout the site?
admin
Wed, 12/14/2011 - 08:15
Permalink
Detection and selection methods
Indeed, there are a number of detection methods available at
admin/config/regional/language/configure. Note that the first detection method that gets a result will determine which language is used. In the context of the current tutorial, the URL method configured to Path prefix is appropriate. See References for more information.Anonymous (not verified)
Thu, 12/15/2011 - 00:31
Permalink
I tried using the option for
I tried using the option for session and user preference but there is something may be I am missing. The switcher doesn't work properly at my end. Can you please guide me with this?
Manuel (not verified)
Thu, 03/22/2012 - 10:53
Permalink
Language icons
marco (not verified)
Thu, 05/03/2012 - 11:38
Permalink
Multilanguage is really crazy
Add new comment