What you want to do is isolate ALL of your text into a separate page. Each message that can be output to the user is defined as a variable. Each language should define all the same variables, but in different languages.
Your PHP script will require() the strings file for your language. Then, whenever anything is output to the client, you'll output the variable name, not the string itself.
Confusing? Yes. Here's what I mean:
<?php // strings.en.php English strings
$greeting = "Hello";
?>
<?php // strings.es.php Spanish strings
$greeting = "Hola";
?>
<?php // strings.gr.php Greek strings
$greeting = "Yia sou";
?>
<?php // index.php Main script
$lang = 'en'; // Default to English;
if (isset($_GET['lang']))
{
$lang = $_GET['lang']
}
require("strings.{$lang}.php");
echo $greeting. "\n";
echo "View this page in:\n";
echo '<a href="?lang=en">English</a>\n';
echo '<a href="?lang=es">Spanish</a>\n';
echo '<a href="?lang=es">Greek</a>\n';
?>
Keep in mind that this is only a very simple example. Any robust open-source PHP application should have a more real-world implementation of this idea. But the concept is the same -- you localize all your output strings into a language-specific string table, and swap out the tables depending on which language you're dealing with. I think that phpMyAdmin does this.
Take care,
Nik
http://www.bigaction.org/