Forum Moderators: coopster
It would like to know there is some function in php so that I can put my site in several languages. I saw a tutorial, but I lost him of my favorites, he taught to do that, he replaced the files by the person's language using.. [#CODE#] Eg:
It puts [#house#] in layout => Then, it was "translated" house in English and casa in Spanish
And in this tutorial had a folder /lang in which I was put the files en.php ( for English ) es.php for Spanish etc...
Anybody had known about anything +/- this way, or some tutorial of how to create layouts for multilanguages?
Obs: It did not want to use Class FastTemplate.php because do not understand a lot of class and I wanted to learn to do that multilanguages system, without using a ready.
Sorry my bad english.
Thanks at once
Robson
Have a file included in each page of yours, lets say languages.php
Inside have something like:
if ($language=="english")
{
$var1 = "Hello world";
$var2 = "This is in english";
}
else if ($language=="funny_language")
{
$var1 = "Greetings in Funny Language";
$var2 = "This is indeed a funny language";
}
// and so on
Now on your pages, instead of typing your text, have a simple echo of the appropirate $var(x) and pass/declare $language in each page yuo want your text to change dynamically.
As i said before, not a great idea for large scale applications
$lang['house']
Depending from the language I fill up that array from one of the ini-Files I have prepared, let's say lang_en.ini and lang_sp.ini.
Choosing english I have
$lang['house'] = 'House';
Coosing spanish I have
$lang['house'] = 'Casa';
Filling up Arrays from an ini-File is pretty easy. Check the php documentation for parse_ini_file().