I am using Ajax via jQuery, and I am trying to translate using the Google Translate Service. The service does not seem to work for me.
What am I doing wrong? How would I
You can do it like this:
$.ajax({
url: 'https://ajax.googleapis.com/ajax/services/language/translate',
dataType: 'jsonp',
data: { q: 'Hello world!', // text to translate
v: '1.0',
langpair: 'en|es' }, // '|es' for auto-detect
success: function(result) {
alert(result.responseData.translatedText);
},
error: function(XMLHttpRequest, errorMsg, errorThrown) {
alert(errorMsg);
}
});
Just remove the key and see if it will work for you
I think you are following the wrong strategy. You don't make AJAX calls to the Google Translate Service directly, the Google Translate Javascript API wraps this all for you.
Look at the examples in the API playground.
There is a plugin for jQuery that leverages the Google Translate API. It definately makes things easier and cleaner.
jquery-translate
What are some of the differences between your code and Google's example code?
Do the examples work for you?
Is it possible that you do not have a valid Google JavaScript API key?
Translate API from Google Translate v1.0 is not working anymore, v2.0 is what are you looking for and is not for free like google search or other services from them.
The price is 20$ for 1 million characters translated.
Here is the official info!