...

View Full Version : How to translate a php variables to English



Mido™
02-01-2012, 09:12 PM
Hi, I need to know a way to translate my php variables to or from English and any other languages, so I could translate the variable use entered to the language I want.
hope if any one could help :)

Fou-Lu
02-01-2012, 09:57 PM
The variable or the value? The variable itself is irrelevant really. The value is a simple search and replace.
If you want it to be swappable, you will need to either write or download something for language management. These can be as simple as constants used as replacements based on the language specified. The most difficult part is optimizing them to never retrieve more than they actually need to do, which is somewhat difficult since you need to capture and replace after the fact.

Mido™
02-02-2012, 09:50 PM
Yes I mean the value, the variable's value but sorry that I just wrote in variable.
and I didn't understand all your other explain but what I want to do is to translate the name of the country from French "or another" to English, so the user will write it in French then I'll translate it to English before inserting to the database.

Fou-Lu
02-02-2012, 10:20 PM
I'm going to say, no on this, at least, not easily.
Sounds like you want to take a phrase input in one language and translate it into another right then and there. This requires a lot more than a simple replacement engine; you need to contact an actual lexical analyst to determine how you convert the syntax of one language into another. Its not just about word replacement at this point, its about grammatical as well.

If its a small set of hard coded words, then yes this is as easy as a simple str_replace. But I'm not sure if you are looking for dynamic conversion which would require a tremendous amount of work, or just something simple.

Mido™
02-04-2012, 02:22 PM
No it isn't a small set of hard coded words and str_replace won't do it, are you could tell me what's the solution and that dynamic conversion who could do it?

jmj001
02-04-2012, 03:46 PM
google translate has an API... that would be your best choice IMHO

http://code.google.com/apis/language/translate/overview.html

Mido™
02-11-2012, 04:46 PM
google translate has an API... that would be your best choice IMHO

http://code.google.com/apis/language/translate/overview.html

can you please explain some in how to use it?

KuriosJon
02-11-2012, 11:30 PM
#1, the API now costs money:


Important: Google Translate API v2 is now available as a paid service only, and the number of requests your application can make per day is limited.

#2, if you want to use it, you'll have to read up on the documentation. It's very thorough and nobody nobody can just tell you how to use it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum