Google's Ajax translation program makes you Global

Source: Internet
Author: User
Google provides support for Automatic Machine Translation in multiple languages, and now Google also provides Ajax API calls for translation functions, supporting website developers to conveniently provide automatic machine translation functions on their own websites. What you need to do is set your application language, and then provide a drop-down box to translate your text into a language supported by Google. The Machine Translation results will be displayed below the drop-down box. With this feature, you can quickly publish your website around the world without worrying about language issues. Of course, this is not the best integration method for translating your website, but for some simple pure text translation functions, such as blogs, it can quickly start to run and work very well. Here to learn more: http://code.google.com/apis/ajaxlanguage/ using Google Ajax API is simple: first Add the following script to the page: JS Code <SCRIPT type = "text/JavaScript" src = "http://www.google.com/jsapi"> </SCRIPT> <SCRIPT type = "text/JavaScript" src = "http://www.google.com/jsapi"> </SCRIPT> then google loads the API function JS Code on the page. load ("language", "1"); Google. load ("language", "1"); before using a function, wait until the page is fully loaded, ajax APIs has a standard method to specify which function JS Code is called during page loading Google. seton Loadcallback (onloadcallback); Google. setonloadcallback (onloadcallback); In the onloadcallback function, specify the source and target languages for translation. JS Code Google. language. translate ('gato', 'els', 'en', function (result) {alert (result. translation) ;}); Google. language. translate ('gato', 'els', 'en', function (result) {alert (result. the following is a complete example: JS Code Google. load ("language", "1"); Google. setonloadcallback (submitchange); function submitchange () {VaR value = document. getelementbyid ('source '). value; var langpair = document. getelementbyid ('langpair '); var pair = langpair. options [langpair. selectedindex]. value. split ('|'); var src = pair [0]; var DEST = pair [1]; Google. language. translate (value, SRC, DEST, translateresult); Return false;} function translateresult (result) {var resultbody = document. getelementbyid ("results_body"); If (result. translation) {resultbody. innerhtml = result. translation;} else {resultbody. innerhtml = '';}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.