how to have a multiple languages in PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rjuy
Forum Newbie
Posts: 15
Joined: Thu Apr 17, 2008 4:56 am

how to have a multiple languages in PHP?

Post by rjuy »

can someone help me in having a multiple languages in a website using PHP?

thanks

- rjuy
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: how to have a multiple languages in PHP?

Post 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.
rjuy
Forum Newbie
Posts: 15
Joined: Thu Apr 17, 2008 4:56 am

Re: how to have a multiple languages in PHP?

Post by rjuy »

ah ok, i'll try this one... thanks

:)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: how to have a multiple languages in PHP?

Post 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
Post Reply