Pitty you have already finished the site!
When thinking of developing a multi-lingual site, you should think of its structure before writing any code.
The most common (but incorrect) way is to have every page "duplicated" (copied, identical, but with different languages), thus accessing "register_en", "register_fr", or changing directory: mysite/fr and mysite/en. Both methods present a serious problem of maintenance: to change a text somewhere, you have to review every page!
A better solution is to use a database, with a table called, say, "languages":
table "languages"
id, varchar (25), index, unique
en, text
fr, text
..
Avantage: to add another language, just add a column in your table!
Set-up a global variable $GLang to "en" for English, "fr" for French etc...
Then, write a php function
function p_text($id)
{
global $GLang;
if ($GLang == "")
$GLang = "en"; // set-up a default
$link = dbconnect();
$sql = "select `".$GLang."` from `languages` where `id`='".$id."'";
$list = mysql_query($sql);
$lst = mysql_fetch_array($list);
mysql_free_result($list);
if ($lst[0] == "")
$lst[0] = $id; // if the field is not set, dislay the ID, so you can correct it
$txt = htmlentities($lst[0]); // allow for accentuated characters
$txt = str_replace("\r\n","
",$txt); // CRLF stored in db use \r\n: convert to HTML
mysql_close($link);
return($txt);
}
and call it when you need:
echo (p_text("welcome"));
entry in table:
id = "welcome";
en = "Welcome";
fr = "Bienvenue";
pt = "Bemvindo"; etc...
See an example (work in progress) at http://aa.web2coders.com
Click a flag to change language!