One of the advantages of Joomla 3 is that is makes it relatively easy to create a multilingual website, without you having to install extensions. In this tutorial, you'll learn how to create a bilingual site. You'll find a complete walkthrough of the steps involved in creating a multilingual Joomla site. This is a free online appendix to the Joomla 3 Beginner's Guide by Eric Tiggeler (Packt Publishing 2013).
Transcript
Step-by-step tutorial on creating a bilingual website in Joomla! 3 This is an online appendix to the Joomla! 3 Beginner's Guide by Eric Tiggeler. For more information, visit the Packt Publishing website or the website accompanying the book, www.joomm.net.
One of the advantages of Joomla 3 is that is makes it relatively easy to create a multilingua lwebsite, without you having to install extensions. In this tutorial, you'll find a complete walk through of the steps involved in creating a multilingual Joomla site. In this example, the default site is in the English language. For users speaking another language, there should be a language switch available giving them access to the same content in a different language. In this example we'll use Dutch as the second site language - but that's just for demonstration purposes. You can follow along with the steps below using any language you want. Although creating a bilingual site isn't complicated, it does involve following a number ofessential steps. Therefore, we'll start with a freshly installed Joomla 3 site, an empty website without sample data. This way, we can keep things simple and get a good idea of the fullprocess. After you've mastered the basic principles, it's easier to apply them to an existingsite that already contains content in one language.
Step 1 - Checking which languages are currently available
After you've installed Joomla, there's one language available. You can check this by navigating to Extensions | Language Manager. In this example, the currently installed language is English (United Kingdom). The column Location: Site indicates this is the language that Joomla uses in the front end (texts such as Read more, Articles and Category). By clicking on Installed - Administrator you can see what language is installed for the administrative interface.
Step 2 - Adding a new language
First, let's add the language files for the language we want to use as the second language on our site. This involves two steps: we'll install the Dutch language pack and we'll tell Joomla! we want to use this as a "content language".
Installing a new language pack
We'll install a Site Language pack. This is the file containing the translated versions of all default texts that come with Joomla (such as Read more).
1. Go to Extensions | Languages. Click the Install Language button.
2. A list of available translations appears. You can easily find the desired language by using the Search by language name field. In this field, enter Dutch.
3. Tick the box to the left of the Dutch language and click the Install button.
4. You'll see a notice: Installing Dutch was successful. Mission accomplished: in the Language Manager overview screen (accessed through Extensions | Language Manager) you can now see there's a another site language available.
Creating a Content Language
The next step is to create a Content Language. Although you've already installed a second language pack (in this example the Dutch site language pack), you still need to add the appropriate details for this language. To do this, you need to add what Joomla calls a Content Language. You can regard this as a "language profile", containing all the details needed for Joomla to be able to use either the English or the Dutch language as "switchable"content languages.
1. In the Language Manager screen, click the Content link in the menu on the left hand side. As you can see, there's just one Content Language - there's no sign of a Dutch Content Language yet. Click the New button.
2. In the New Content Language screen, add the following details for the new language:
- Title: enter Dutch (NL). This is the language name that will be displayed in the Joomla backend in articles, modules and other items that you can assign a specific language to.
- Title Native: for Dutch, enter Nederlands. This the original language name. This title will be displayed in the Language Manager, in the list of Content Languages.
- URL Language Code: enter nl. This is the code that Joomla will append to the page URL. If nl is entered, the output will be: www.example.com/en/. Every language installed must have a unique code.
- Image Prefix: enter nl. This is the language code, just as English has en or Frech has fr. Joomla uses this code to display country flag images enabling the visitor to select an site language. When you enter nl, Joomla will display the nl.gif flag image file found in the media/mod_languages folder. To find out which language flags are availble, refer to this folder.
- Language Tag: enter nl-NL. This tag consists of the language code (in lower case), a hyphen and the country code (in uppercase). If you're not sure about the Language Tag, you can find it next to the language name in the list of installed site languages in the Language Manager.
- Status: this should be set to Published.
- Access: this should be set to Public.
3. Click Save & Close. The Content Language profile is ready.
Step 3 - Enabling the Language Filter plugin
Joomla comes with a language filter plugin, which enables the CMS to recognize the different installed languages and display only the content relevant to the current language. The next step is to enable this plugin.
1. Go to Extensions | Plug-in Manager. Using the search box, search for the System - Language Filter plugin.
2. Click the System - Language Filter name to change its settings. First make sure Status is set to Enabled.
3. Click the Basic Options tab. Check if Item associations is set to Yes. To create search engine friendly URLs in the multilingual site, set Remove URL Language Code to Yes.
4. Click Save & Close. You've now got the language files set up properly and you've switched on Joomla's built-inLanguage Filter. By default, this plugin will try to detect the language settings of the sitevisitors browser and display the site in this language (if this is present).
Step 4 - Adding multilingual content
The next step is to create the actual content that needs to be displayed in different languages. To neatly organize the content that belongs to different languages, you need tocreate specific categories holding (in this case) English and Dutch content.
Creating language categories
We'll add two top-level categories: one which will contain our English content, the other onefor Dutch content.
1. Navigate to Content | Category Manager and click New to create a new top-level category. This first new category will become the container for all Dutch articles, so let's call it Dutch. In the Language drop-down list, select Dutch. As it's a top-level categogyr, it should have No parent. Save this new category.
2. Next, create a new top-level category called English. As the language, select English (UK). Click Save & Close. The Category Manager should contain both a category called Dutch and a category called English.
You've now got two categories in your site. In real life, you'd probably want to organize the site content using subcategories of these two main categories. In this example, we'll leave the categories as they are.
Adding content to the new categories
Next, create a set of (dummy) articles. We'll create a few English articles and their Dutch counterparts. In this example, we'll create four articles in the English category and four articles in the Dutch category.
1. Navigate to Content | Article Manager. Create a new article called English Article 1. Add some dummy text. Make sure to assign the article to the English category. In the Language drop-down list, select English.
2. Repeat the actions described in the previous step to create a set of articles called English Article 2, English Article 3 and English Article 4.
3. You've now got four English articles. Instead of creating four corresponding Dutch articles from scratch, let's copy the English articles. To do this, select all four articles in the Content | Article Manager screen and click the Batch button.
4. In the Batch process the selected articles popup screen, choose the following settings:
- Set Language: Dutch.
- Select Category for Move/Copy: Dutch.
- Click the Copy select box and click Process.
5. You've now got a set of eight articles: four articles assigned to the English category and their copies, assigned to the Dutch category. Open the first of the four articles that are assigned to the Dutch category. Change the following details:
- Title: enter the Dutch title. In this case we're only testing things out, so we won't bother translating. Let's enter Dutch Article 1.
- Under Publishing Options, delete the contents of the Alias field. Joomla will insteadadd a unique alias for this article after you've saved the article.
- In the article text, just change a few words to be able to be able to check later if the "Dutch" text is displayed.
- Click Save & Close.
6. Next, open the other Dutch articles one by one and change the details accordingly. The output should be Dutch Article 2 to Dutch Article 4, all assigned to the Dutch category, assigned to Language: Dutch.
The (dummy) content is ready. We've got two small groups of articles; each of these articleshas been assigned to the appropriate language.
Step 5 - Creating menus for the multilingual content
Next, we'll create a menu for each of the languages. As you would expect, we'll need a menupointing to the English articles, and a separate menu pointing to the Dutch articles.
1. Navigate to Menus | Menu Manager and select Add New Menu. First create a menu for the Dutch language articles. As the Title, enter Dutch Menu. As the Menu Type, enter dutchmenu. Finally, add a Description (ie Menu for Dutch content).
2. Click Save & Close. Now create another menu for the English language. As the Title, enter: English Menu. As the Menu type,enter: englishmenu. Add a Description and save the menu.
You've now got two sets of content, and two menus, ready to be filled with menu items.
Adding menu items
The two new menus are still empty, so let's add a set of menu items to them.
1. Navigate to Menus | Dutch Menu | Add New Menu Item. We'll keep it simple and create a menu link of the Single Article type. Make this menu link point to Dutch Article 1. As the Menu Title, enter Dutch Article 1. Make sure the Menu Location is Dutch Menu and set the Language to Dutch.
2. Repeat the actions described in the previous step until you've got four menu items in the Dutch Menu, each pointing to one of the four available Dutch articles.
3. Now navigate to Menus | English menu and create four menu links pointing to the four English articles. To do this, repeat the actions you took in step 1 and 2, changing the details as needed.
The outcome should be a set of four menu links in the English menu
Assigning language-specific home pages to the new menus
Your English and Dutch menus both contain all necessary menu links. However, Joomla needs to know what menu link in either of these menus should be the default link (the default homepage to be displayed for either the English site or the Dutch site). Let's set one of the menu items to be the default homepage for this language.
1. Navigate to Menus | Menu Manager and click the name of the English Menu to open it.
2. Click on the star in the Home column next to the first article.
3. The star icon changes to an image of the British flag, indicating this is the default page for the English part of the site.
4. Navigate to Menus | Dutch menu and click the Home star next to the first Dutch article. The star turns into a Dutch flag.
Connecting menu links to their translated counterparts
Although you have two sets of articles (orginal articles and their Dutch "translations"), up to now there's no connection between these articles. Joomla has no way of knowing what Dutch article should serve as the translated alternative of a particular English menu item. Let's connect (associate) the English menu items with their translations.
1. In the Menu Manager, open the Dutch Menu and click the first menu item to edit it (in this example, this is the Dutch Article 1 menu link).
2. You'll notice this menu item has a separate Associations tab. Click this tab and click the English (UK) drop-down list. Select the appropriate English menu link: English Article 1.
3. Save this menu item.
4. Repeat the previous steps to create associatons for all four Dutch menu links. Open each menu link, select its appropriate English counterpart and save it. As a result, you should now have four Menu Items that are associated with Dutch MenuItems. In the Menu Manager: Menu Items screen, you can easily check this: in the Association column, an icon (a chain in a blue circle) is displayed. Hover your mouse cursor over the image to see the associated menu items.
Finalizing the new menus by adding menu modules
Both new menus have been created, and menu links have been assigned to them. However, as is the case with every new menu created in Joomla, you'll also have to add a menu module in order to be able to display the menu on the site. Let's add these modules for both menus.
1. Navigate to the Menu manager. Locate the Dutch Menu and click the Add a module for this menu type link in the Linked Modules column.
2. In the Module Manager: Module Menu screen, enter the following Title: Dutch Menu. In the Language drop-down list, select Dutch (NL).
3. In the Position drop-down list, select position-7. Click Save & Close to commit changes.
4. Add a menu module for the English menu by repeating the previous steps, changing the details as necessary: in the Menu Manager, click the Add a module for this menu type link, name the new module English Menu, set the language to English (UK), assign it to position-7 and click Save & Close.
Unpublishing the default Main Menu
Apart from the two new menus, the website also contains the Main Menu that's part of the Joomla default setup. If you've installed Joomla without sample data, this menu containsonly a Home link. Although the bilingual site will use the new English Menu and the new Dutch Menu, Joomla will still need the default main menu and the Home link in it to function. Joomla also requires the Main Menu module to remain assigned (as it is by default) to Language: All. However, the Main Menu doesn't need to be displayed any more on the site. For this reason, we'll unpublish the menu module associated with the Main Menu.
1. Navigate to Extensions | Module Manager, locate the Main Menu module and click its Title to edit it.
2. Change the Status to Unpublished. Save your changes.
The menus for the multilingual content are finished. Just one more step to go: adding alanguage switcher enabling web visitors to select their prefered language.
Step 6 - Adding a Language Switcher
If you were to leave the site as it is, you would have two sets of articles, one Dutch, one English. However, only one menu would be displayed: either the English Menu or the Dutch Menu. Joomla would decide between serving English or Dutch content depending on the language settings of the visitors browser.
However, we want the visitor to be able to actively switch to the translated content in another language. To add this functionality, we'll install the language switcher module that comes with Joomla.
1. Go to Extensions | Module Manager. Click New and create a new module of the Language Switcher type.
2. Enter a Title, ie Choose your language.
3. As the Position, select position-7.
4. The Language drop-down box should remain set to All, as this module will be displayed regardless of the selected language.
After you've saved the new module, have a look at the front end of the site. In the right column the language switch should be displayed.
Step 7 - Exploring the multilingual site
Congratulations, your modest but fully functional multilingual site is finished! When the user visits the site using a browser which is set to use the English language, Joomla will displaythe site with the English content: all articles and modules that have been assigned English astheir content language. Should visitors wish to see the Dutch version of the site contents, they can click the Dutch flag icon in the Language Switcher.