Page 1 of 1
how to have a multiple languages in PHP?
Posted: Mon Dec 08, 2008 11:31 am
by rjuy
can someone help me in having a multiple languages in a website using PHP?
thanks
- rjuy
Re: how to have a multiple languages in PHP?
Posted: Mon Dec 08, 2008 1:01 pm
by watson516
I am going to assume that you are attempting to translate your website into multiple languages and want php to automatically select the proper language? Yes? Great!
I have never attempted this but you might want to grab the browser's default language with $_SERVER['HTTP_ACCEPT_LANGUAGE'] and then parse out the language the website user would like to use. This might be wrong on someone's computer so you might also want to have a drop down box or something to select language.
After you determine the language you would probably have to either include different files or grab whatever language from the db.
Re: how to have a multiple languages in PHP?
Posted: Mon Dec 08, 2008 2:09 pm
by rjuy
ah ok, i'll try this one... thanks

Re: how to have a multiple languages in PHP?
Posted: Mon Dec 08, 2008 2:17 pm
by Eran
Gettext is the common standard for maintaining multi-lingual versiosn of the same content. Check out the PHP gettext functions -
http://www.php.net/manual/en/ref.gettext.php and also Zend_Translate, a component for translations that accepts several data-sources for translations (including gettext) -
http://framework.zend.com/manual/en/zend.translate.html
Also, check out the PHP manual sections on internationalization -
http://www.php.net/manual/en/refs.international.php