NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home / News / Webmaster / Tips and Tricks

Tips and Tricks


Automatic Text Translation with Javascript

An example of Google AJAX language API implementation

By Catalin Bocanu, Web News Editor

22nd of March 2008, 13:11 GMT

Adjust text size:


Google Language Learner
Enlarge picture
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:

CODE

Google AJAX Language API Usage Example


google.load("language", "1")
function translate() {
google.language.translate("The First Automatic Translation", "en","fr", function(output) {
alert(output.translation)
})
}
google.setOnLoadCallback(translate);








In order to add the Language API in your page head (the loader will include all the Google APIs (line 4)), you must specify the Javascript directive google.load("language", "1"), which will load the version 1 of Google AJAX Language API. The function translate will allow the translation of the string 'The First Automatic Translation' from English to French. The translation result will be displayed in an alert window. The directive google.setOnLoadCallback(translate) will permit you to use API functions after the page has loaded. If you comment the google.setOnLoadCallback(translate) line by adding // characters in front of it, you will notice that after recalling the page in your browser address bar, the alert window will not appear after the page loading.

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.

TAGS:

Google AJAX Language API | Automatic Translation | Translation Tools | Javascript Translator | Google Translation Tools
Read by 9,043 user(s) | Add comment | Link to this article TWEET THIS


Article rating:
Good (3.0/5) 8 vote(s)    

Subscribe to news | Print article | Send to friend

© Copyright 2001-2009 Softpedia
Contact:

 

 

SEARCH THE NEWS ARCHIVE :




Today's News
| Yesterday's News | News Archive


MORE RELATED ARTICLES:


ManagedQ Search Application

A New Functionality for Google Navigation Toolbar

Get a Simple Blog Application for Beginners

Useful Secrets of Gmail Service

A Promising Alternative for Google Reader

Methods to Block Spiders

Popular Free Services For Blog Creation

A Free WordPress Theme with Integrated Google AdSense

Automatically Save and Crack Flash Games, Movies and Videos

Deployment of a Free, SEO Ready Made Website in 10 Minutes

User opinions:


Comment #1 by: webprogrammer on 24 Mar 2008, 04:38 GMT reply to this comment

Well, its pretty nice stuff. But I think you have missed out a very important point to mention. This service is does not support more than a 500 character request. Neither they are planning to increase the limit in near future.
see this,
http://groups.google.com/group/Google-AJAX-Search-API/browse_thread/thread/036689f97278375e#

Thanks
-Webprogrammer


Comment #2 by: Sur'at on 19 May 2008, 12:22 GMT reply to this comment

HI!
This program is very nice.
I have a little problem.
I must to find more information about text translators.
If have it please send my mail.
Thank you!
Bye!

Share your opinion:

Your Name:
Your Email Address:
(will not be used for commercial purposes)
Solve this to prove you're not a bot: =
Your review/opinion:

 




Windows tabGames tabDrivers tabMac tabLinux tabScripts tabMobile tabHandheld tabGadgets tabNews tab

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   ENTER NEWS SITE   |   ENGLISH BOARD   |   ROMANIAN FORUM