QUOTE(Mark @ Jun 22 2008, 05:34 PM)

The easiest way is to make a en.php and fr.php file containing all your text in descriptive named variables. And then at the top you set which language file to import. e.g.
CODE
switch ($_GET['id'])
{
case 'en':
require ( "../languages/en.php" );
break;
case 'fr':
require ( "../languages/fr.php" );
break;
}
And then in the langauge files you'd have it like
$aLanguage['home-page-header'] = "Welcome to mysite!";
$aLanguage['home-page-explanation'] = "Welcome to mysite! Here we do this and this and this. We have lots of fun and do lots of things. zOMG."
And then in your php where you fill in the HTML you just use the the $aLanguage variable, and whichever language is set will determine which $aLanguage variable it uses (english or french)
This is the best solution. Here is a tutorial for a non-programmer

(WARNING: PHP Codes included)
Alright, as always, lets do it with a demo and not try to do this for universal projects. Demos work better and once you learn you can go universal (Apply it for your site in simple terms

)
Alright, first of all create a page index.php in a testing directory you will delete later on when you are done with this tutorial.
In index.php we will have it check which language file we will need, and to make it simple, lets use a technique that is used in a templating system. Me would have like three files in the first directory... just to make it work better.
The files in the directory would be...
- index.php
- includes.php
- language.php
- language/en.php
- language/fr.php
Index.php is the main page for public view... includes.php would be what the name infers... it would include files so you could include one file into one file that is included into all files. This way, if you create one file that needs to be included into all files and there is a file that is already included into all files, than you can include that file into that file and it is included into every file automatically... saves time

Also good if you want to set universal variables

I do this and it serves me well.
Obviously language/en.php and language/fr.php are the language files.
language.php would determine which language to use for rendering. If no language is set, it would default to english. Here is how index.php would look like in the example (The content would grow in the example).
CODE
<?php
session_start();
include('includes.php');
?>
And here is how includes.php would look like
CODE
<?php
include('language.php');
?>
And here is how language.php would look like
CODE
<?php
$language = array('fr','en');
$lang = ((isset($_SESSION['lang'])) ? $_SESSION['lang'] : $_GET['lang']);
$lang = ((!in_array($lang) && !empty($lang)) ? $_GET['lang'] : 'en');
if(!isset($_SESSION['lang']) && isset($_GET['lang']))
{
$_SESSION['lang'] = $lang;
}
include("language/{$lang}.php");
?>
en.php would look like...
CODE
<?php
$lang['helloworld'] = "Hello World!";
$lang['maincontent'] = "Welcome to my site. I appreciate the fact that you came here.";
$lang['lang'] = "English";
$lang['title'] = "Language Test";
?>
and the fr.php would look like
CODE
<?php
$lang['helloworld'] = "Bonjour tout le monde!";
$lang['maincontent'] = "Bienvenue sur mon site. J'apprécie le fait que vous êtes venu ici.";
$lang['lang'] = "Français";
$lang['title'] = "Langue d'essai";
?>
(Sorry for the poor translations... I don't know French so I used google translator

)
So, now your index.php would look like...
CODE
<?php
session_start();
include('includes.php');
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><?php echo $lang['title']; ?></title>
</head>
<body>
<p style="color: #CECECE;">Language <?php echo "<a href=\"".$_SERVER['REUQEST_URI']."?lang=en\">English</a> <a href=\"".$_SERVER['REUQEST_URI']."?lang=fr\">Français</a>\n"; ?></p>
<hr />
<h1 style="text-align: center;"><?php echo $lang['helloworld']; ?></h1>
<p><?php echo $lang['maincontent']; ?></p>
</body>
</html>
That is all to it. Real easy once you create the language files and the link and that is all...
If you need anything else ask here...