I have a text box and I want to enter a string in language A

I have a text box and I want to enter a string in language A and send it to Google Translate . After Google translated it, I want to take a new line (in B language) (after the translation) and save it in some variable.

How can i do this?

+1
source share
2 answers

The basic idea is shown in a simple example of a language translation as follows:

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

translationis the identifier of your text field. In this case, when you put the translation result.

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

"Hello world" "en" () "es" ().

JavaScript.

API Google AJAX Language.

0
+2

All Articles