views:

784

answers:

4

How is language translation handled in PHP? I need to change the language of a site based on user preferences. Also, I may not have access to the client source code. At most, I could upload a folder of my own and do the dynamic translation myself.

As far as I know, the basic process would be: Send Language 1 output to global function -> translate -> Output to screen.

I need someone to help me out with the specifics in PHP.

Are there any standard implementations that I am unaware of? Has anybody done such a thing and if so, how did you do it?

Thanks.

A: 

You have to use Gettext

slipbull
+1  A: 

I've been looking for an answer to this question as well and even though I couldn't solve it with php I think it can be done with google's language api.

There appears to be a standard way of doing what you want to in php, I think it's what wordpress uses http://codex.wordpress.org/Translating_WordPress and it's very similar to you making your own dynamic translation system, you can also do this with zend apparently.

framework.zend.com/manual/en/zend.translate.html

But going back to the google api

code.google.com/apis/ajaxlanguage/

What you could do is use ask the user their language of preference and save that variable either in a cookie, session, or database, then pass that variable to the api and let it handle the translation.

SoftwareDev
A: 

You can use this idea: http://www.phpcollection.com/spell-check-php-yahoo-api.html

inakiabt
A: 

Try http://www.phptranslator.com It can translate your website in the background using Google API.

sehhorng