Globalization Services

Building a Multilingual Site in Drupal 7 - Recipe 2

Esteban Solano
Engineer

Blog Site in Multiple Languages: Recipe 2

In our last blog post, we saw how to set up a simple website in a foreign language. Like our last recipe, this one is very easy too.  The main difference lies in the fact that we need to give users the possibility to choose their preferred language.  Content will not be translated to each language, but the user needs to be able to navigate the site in their preferred language, so that they can find what they’re looking for a blog post in a language they understand.

To achieve this, we follow the same steps we did in our last blog post, with a couple changes: First, instead of just adding one language, choose all the languages you will support.  Remember that since we installed and enabled the Localization Update module, it will automatically download the available site translations for your site’s interface.  Second, configure the “Detection and Selection” settings.

So let’s go ahead and do the second change we need. Go to /admin/config/regional/language and select the “Detection and Selection” tab.  Here, you will be presented with several language detection methods.  You will need to setup at least one.  The most common one is the URL detection method.  When you configure it, you can either choose “Path prefix” or “Domain.”  The first is the easiest one.  It simply uses predefined prefixes in your site’s URL to determine what language is being used; like http://example.com/es for Spanish or http://example.com/de for German.  The second requires some additional server modifications so that your site can respond to domains such as http://es.example.com for Spanish or http://de.example.com for German.  Let’s use “Path Prefix” for now.  Save configuration, and you are good to go.

Screen shot 2012-07-31 at 7.51.33 PM.png

 

Now that we have a way for the system to know when to present one language or the other, let’s give the user the possibility to pick one.  The Locale Module provides a block that you can enable, giving users the possibility to pick the language of their preference.  Go to /admin/structure/block and look for the “Language Switcher” block, place it in a region where users can easily find it; like the “Sidebar First” or the “Help” regions in a Bartik theme.  If you’ve been following me, you should see something like this:

Screen shot 2012-07-31 at 8.01.24 PM.png

You can see that the selected language is Spanish, and almost all of the user’s interface has been localized so that Spanish users can understand and navigate through your site.

This concludes this second recipe.  So far we’ve seen a couple of very basic scenarios for Multilingual websites.  As you can see, setting up Multilingual websites like these is a no-brainer.  These simple steps can open up the possibilities of your site by making it available to a broad variety of users with very little effort.  This process would otherwise be a laborious task to do without such wonderful Multilingual features that Drupal provides.

Our next blog post will deal with a far more complex Multilingual website.  You’ll learn how to handle the translation workflow of your content and other interesting topics such as content moderation and automated translation techniques.  I hope the recipes we’ve seen so far will help you in your own Multilingual projects. 

More about Globalization Services

Global Strategy
The question is not why, but how to go global?  
Medical Device Industry
The Medical Device Industry is Growing  
Achieve is proud to be a Lingotek partner and we are excited to work with them and their innovative Translation Management System (TSM)