Page 1 of 1

Building a multilingual site using PHP

Posted: Fri Mar 14, 2003 11:11 am
by kendall
Hello,

I would lie to get some advice concerning in building multi-lingual sites dynamically using PHP

i have a website that i need to build with an english and a spanish version.

I am still novice in PHP but would like to attempt a plan that would bring up the appropriate version dependant on the users selection.

I also want to do it without doing the same thing twice if you understand what i mean.

IS there any tutorials or has anyone built a site in comparison

i want to know like

what is the best approach
what methods do i use
would this be easier with javascript?

i was thinking about using a code that switches the BASE URL from a english to a spanish folder
e.g.

BASE URL = http://www.thedomain.com/spanish
if english
echo BASE URL = http://www.thedomain.com/english

any other suggestion of how i can approach this

Kendall

Posted: Fri Mar 14, 2003 11:57 am
by volka
this board for example uses language templates.
e.g. there is a file lang_main.php in language/lang_english and language/lang_german.
lang_english/lang_main.php sets $lang['Post_new_topic'] = 'Post new topic'; but lang_german/lang_main.php sets $lang['Post_new_topic'] = "Neuen Beitrag schreiben";.
Dependig on which file you include echo $lang['Post_new_topic'] will output the english or the german version.
Wether this is applicable for your website depends on the amount of text and the complexity to install the template(s).

Posted: Sat Mar 15, 2003 4:07 am
by m3mn0n
I would simply try to code some sort of automatic translation fetching device from Bablefish.

Or simply point your users to Bablefish or a similar translation site, but remember translators might not pick up slang or some "politically incorrect" sentences and the translation may not work properly.

What volka suggested is a very good way to do a multilingual site. It requires much more work and effort than the way i suggested but it gets the job done. And well might i add since you are defineing all the variables and not some strange translator some odd-named company owns. :)