HI frnds..

i need a help from u..
now i am going to do a ecommerce gifts website.
here i need to change total site from english to french,italie...based on selected language from select box
how can i do this..plz help me asap..
is there any software or any procedure plz tell me..

thanks & regards

8 Years
Discussion Span
Last Post by diafol

There are a few solutions. You can use off-the-shelf solution e.g. open source CMS Joomla with Joomfish, or design your own. I prefer to design my own as it gives a greater degree of flexibility.

Here's my method:
1. I create a i18n folder and create my language files by placing the static phrases as arrays, e.g.


2. Into these files place the static text array:

$iTxt = array(
'index_title'=>'Croeso i\'m Hafan',
'index_preamble'=>'Dyma\'r wefan orau yn y byd',
'index_main_title'=>'Ceilliau\'r Gath',
       [etc, etc.]

3. Include the correct language file into your pages (before the DTD) by using your current language variable (e.g. $lang). include($_SERVER['DOCUMENT_ROOT'] . "/i18n/{$lang}.inc.php"); 4. Insert placeholders into your HTML


You may find that an Model-View-Control/Templating system like Smarty may be useful here.

Also, your $lang variable must carry forward from page to page either as a cookie or $_SESSION variable or as a database value.

You can retrieve the language from a dropdown and $_POST variable:

<select id="lang" name="lang">
  <option value="cy">Cymraeg</option>
  <option value="en">English</option>

In your form handler:

$lang = addslashes(htmlentities($_POST['lang']));
$_SESSION['lang'] = $lang;

My database tables are listed so that they contain language-labelled fields, e.g.
desc_cy, desc_en
description Welsh, description English.
This is probably not the most efficient way of doing things, but the mysql calls are extremely easy to manipulate:

$sql = mysql_query("SELECT desc_{$lang} FROM mytable WHERE ...");

Alternatively, you could look at gettext and po/pot files using PoEdit. I haven't used this yet, but it looks promising. Keeping track of changes to different language files is very difficult, so an indexing system like this should be good.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.