If you publish the text content of a website in multiple languages, the chances of having more visitors will be increased. There are many alternatives to provide multilanguage support for a given website and in this direction automatic translation methods will decrease the time of content publishing.
Google AJAX language API (application programming interface) allows you to translate various words or phrases from 13 languages using 29 translation pairs. Besides the text translation, Google AJAX language API gives you also the opportunity to perform the language detection using only Javascript. This method is a very efficient alternative for offline translations tools.
Regarding the implementation of Google AJAX Language API in your own HTML pages, applications or scripts, let's consider the next Javascript code integrated in a HTML page:
google.load("language", "1")
function translate() {
google.language.translate("The First Automatic Translation", "en","fr", function(output) {
alert(output.translation)
})
}
google.setOnLoadCallback(translate);
In this situation, you can use the Translate button. The corresponding code situated into the page body tags demonstrates how to call a Javascript function from HTML. You can change the script by adding the corresponding Javascript directive for language detection of translation output. For more information, you can check the Google AJAX Language API documentation.