There are a few third party add-ons for managing multi language website.

Here I would like to share an easy way to manage multi-language website without using any third party add-on with the following steps.

1) Directory Structure of multi-language website:

Let’s start with example. We are going to design/develop an ExpressionEngine website which would have 3 languages Danish (da), French (fr) and English (en). First step would be to identify language global variable for each language. If you look into the root file structure of your ExpressionEngine installation, you can see:

  • images
  • system
  • themes
  • index.php
  • admin.php

Well, there should be index.php file which be called for each language for which we need to create directory structure like:

  • images
  • system
  • themes
  • index.php
  • admin.php
  • da/index.php
  • fr/index.php

No need to take much trouble. Just create new directories de/ & fr/ and paste the index.php file of root within these.

The URLs of the website will be:

English language website: http://www.yoursite.com

French language website: http://www.yoursite.com/fr/

Danish language website: http://www.yoursite.com/da/

2) Setting the language global variable:

You need to add these 2 lines of code anywhere within the specified files:

/index.php

/fr/index.php/

/da/index.php/

In the index.php, these language global variables should be always above this line of code:

If you are thinking that the language code can affect the URL segments. NO, URL segments will work same as before like:

http://www.yoursite.com/index.php/segment_1/segment_2/segment_3

http://www.yoursite.com/fr/index.php/segment_1/segment_2/segment_3

http://www.yoursite.com/da/index.php/segment_1/segment_2/segment_3

The index.php file can be removed easily for all with the help of HTACCESS.

You may need to update the system path within newly created index.php files of language folders.

3) Managing the content from Control Panel:

In the ExpressionEngine, we manage the website contents via the channel entries. In the multi-language website, the contents can be managed for different languages within the channels:

i) Creating one channel for each language:

Let you would like to manage multi-language for the news content. You will need to create 3 channels news_en, news_da and news_fr i.e one channel for one language. No need to create separate field group for each channel. You can create one field group assigned to all 3 channels.

Simply you can write the channel entry tag:

{exp:channel:entries channel="news_{language_code}”}

{title}

{news_content}

{/exp:channel:entries}

In the above example code, the channel parameter value is associated with the {language_code} which will fetch the global variable’s value of {language_code} so for the URL like http://www.yoursite.com/fr/index.php/french-news-title, the entry of news_fr channel will be populated.

In the same way, you can create the channels for different languages.

ii) Creating custom field for each language within a channel:

If you wouldn’t like to create as many channels as languages, you as many custom fields as language for same content.

Like you have created a channel news and for publishing news_content in 3 languages, you have to create 3 fields news_content_en, news_content_fr and news_content_da.

{exp:channel:entries channel="news"}
{news_content_{language_code}}
{/exp:channel:entries}

Well, on the website pages, there may be some static content i.e not being populated from the channel entries. You can manage these either by Global Variables or by Snippets. In the same way creating one global variable or snippet for a language.

Like if you are creating a global variable “left_contents” and for same content in 3 languages, you have to create left_contents_en, left_contents_da and left_contents_fr, It can be populated within the template with tag: {left_contents_{language_code}}.

The snippets can be managed in same way.

You can manage the category’s field or description in same way.

More static contents can be managed via conditions like:

{if language_code == 'fr'}

French Text

{if:elseif language_code == 'da'}

Danish Text

{if:else}

English Text

{/if}

4) Language switcher menus or options:

There should be options so that any site visitor can switch from one language to another from any page but that page might be same. If you are using ExpressionEngine v2.5.4+ then it will be fairly easy with the Standard Global Variable multi-language-website-with-expressionengine.

Like:

Otherwise the easy way will be to put conditions like:

You can download ExpressionEngine’s different language packs and install it.

I hope, it would help you to manage a multi-language website easily. If you have any suggestion/comment, don’t hesitate to post comment. I ‘ll reply back asap.

There are some good modules for multi-language website:

  1. Multi Language Module
  2. Multi Language Support (MLS)
  3. Transcribe
  4. Publisher
  5. CI Multilanguage Module

There is a good Multilingual Text Fieldtype for ExpressionEngine (Beta).