Your EE module, plugin, and extension marketplace!

Our Newsletter


Click to enlarge

Multi Language Module

RRP:
Price:
$39.95
Vendor:
PutYourLightsOn
Brand:
Weight:
Rating:
(1 product review)
Availability:
Instant Download
Shipping:
Gift Wrapping:

Quantity:


Product Description

The Multi Language Module is an Expression Engine add-on that allows you to create phrases in multiple languages, which you can then display in your site templates and call from other add-ons. It comes with 3 languages by default (English, Spanish, Italian) but you can add and delete languages as you please.

* Current version 1.01 (released 11 February 2009)
* Works with ExpressionEngine 1.6 and higher.


Concept

To create a phrase you simply enter a phrase index and add the phrase in as many languages as you want.

To display a phrase, you simply use an expression of the format{exp:multi_language:phrase index="hello"}. Depending on the user's language, this will appear as "hello", "hola", "ciao", etc., assuming you have already entered these translations.

The user's language is determined by the url. So for a webpage at mysite.com/links/ the italian version will be at mysite.com/it/links/. This makes for easy navigation and setup in Expression Engine.


How It Works

The Multi Language Module uses a global variable in the path.php file to determine the current language. This is then used to retrieve phrases and weblog entries in the user's current language.


Setting the Global Variables

First, open up the path.php file in your website's root directory. Set the global variables in the last line:

$global_vars = array(
	"base_url" => "http://www.mysite.com/", 
	"user_language" => "en"
);
	

Change mysite.com to your domain. In this case English (en) is your default language.

Each new language requires a folder, for example "es" for Spanish, to be created in your website's root directory. Open the path.php file in that directory and set the global variables as follows:

$global_vars = array(
	"base_url" => "http://www.mysite.com/es/", 
	"user_language" => "es"
);
	

You will now have two new global variables available to you in your templates and add-ons.

base_url can be used for adding links in your templates while keeping the language in your url.

user_language contains the current language.


Creating and retrieving multi-lingual phrases

Phrases can easily be created on the Multi Language Module page. Just enter a phrase index, which will be used to reference the phrase, and then enter it in as many languages as you want.

To retrieve a phrase in the templates, use{exp:multi_language:phrase index="hello"}, replacing hello with the phrase index.

Screenshot

Screenshot


Multi-lingual Weblogs

Weblogs can be easily set up to handle multi-lingual fields. For each new language, just add a custom weblog field for title and body.

To add Spanish for example, add one custom field called title_es and one called body_es. These can then be used to hold the translations of the default title and body fields.

Then in your templates use the following method for calling weblogs:

{exp:weblog:entries weblog="my_weblog"}
	{if user_language == "en"}{title}{if:else}{title_{user_language}}{/if}
	{if user_language == "en"}{body}{if:else}{body_{user_language}}{/if}
{/exp:weblog:entries}
	

Screenshot


Switching Languages

You can switch language using javascript and php, but in my opinion the best way is to use a permanent link (for SEO purposes):

<a href="{site_url}{if segment_1}{segment_1}/{/if}{if segment_2}{segment_2}/{/if}{if segment_3}{segment_3}/{/if}">View site in English</a>
<a href="{site_url}es/{if segment_1}{segment_1}/{/if}{if segment_2}{segment_2}/{/if}{if segment_3}{segment_3}/{/if}">Ver sitio en Espa�ol</a>
	


Removing index.php from your URL

If you use the exclude list method to remove index.php from your URL then you must add each language as an exception to the rule. For example:

RewriteEngine on
RewriteCond $1 !^(es|it|images|system|themes|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L] 
	

The language directories already include a .htaccess file that removes index.php.


Installation

Download and unzip multi_language.zip, then follow the steps below:

  1. Upload the multi_language folder to the system/modules folder
  2. Upload lang.multi_language.php to the system/language/english folder
  3. Add two new global variables to the path.php file in the root directory of your site, changing mysite.com to your domain:
    $global_vars = array(
    	"base_url" => "http://www.mysite.com/", 
    	"user_language" => "en"
    );
    		
  4. Upload the es and it folders to the root directory of your site (if you want those languages), changing system_path if necessary and mysite.com to your domain in thepath.php file in each folder
  5. Duplicate the es folder for each new language you want, changing user_language to your domain in path.php, and upload it to the root directory of your site
  6. Install the Multi Language module (Control Panel -> Modules -> Install)
  7. Add or delete languages in the module (add labels for new languages in thelang.multi_language.php file)
  8. Start adding phrases in the module
  9. You can replace {path=home} with {base_url}home in your templates to maintain the user's language in links

 

License

By purchasing the Multi Language Module you agree to the following conditions:

  • One license grants the right to perform one installation of the Multi Language Module. Each additional installation requires an additional purchased license.
  • You may not reproduce, distribute, sell or transfer the Multi Language Module, or portions thereof, to any third party.
  • All copyright and proprietary notices within the Multi Language Module files must remain intact and unaltered.
  • The Multi Language Module is provided "as is", without warranty of any kind.
  • You assume all risk associated with the installation and use of the Multi Language Module.

Changelog

Version 1.01

  • Fixed a bug which showed an update notification when no update was available
  • Made remove and add language buttons visible when no phrases exist

 


Find Similar Products by Category

Write your own product review

Product Reviews

  1. This is an EXCELLENT module

    Posted by Nathan on 4th Jun 2009

    This is an EXCELLENT module and I will recommend it to anyone attempting to turn their EE site into a multi-language site.

    You can be expecting a long time customer and again, Ben, thank you for all of your help and for designing such a wonderful module!


Add to Wish List

Click the button below to add the Multi Language Module to your wish list.

Related Products

You Recently Viewed...




Clicky Web Analytics