views:

65

answers:

2

OK I will try to ask it again.

I have a text-box and I want to enter a string in language A and send it to "google translate". After Google has translated it I want to take the new string(in language B) (after translation) and store it in some variable.

I hope this time it is more clear.

How I do it??

+1  A: 

Read on Google AJAX Language API to understand how you can use Google's translation services programmatically.

Eli Bendersky
A: 

The basic idea is shown in a simple example of Language Translation like this:

google.language.translate("Hello world", "en", "es", function(result) {
  if(!result.error) {
    var container = document.getElementById("translation");
    container.innerHTML = result.translation;
  }
});

translation is the id of your textbox. In this case where you put the translation result.

result is the translation itself. You can assign it to a new variable in any way you want.

In the above example you're translating "Hello world" from "en" (English) to "es" (Spanish).

The above code is written in JavaScript.

Take a look at Google AJAX Language API for more detailed steps.

Leniel Macaferi
in what Language this is??
nisnis84
@nisnis84: This is Javascript. To use it from C/C++ you'd need something like libcurl and a JSON parser
Eli Bendersky