Search Perform an advanced search query SOFTPEDIA
 
SOFTPEDIA
Updated one minute ago
HomeSubmit a program for being reviewedAdvertise on our websiteGet help on surfing our websitesSend us your feedbackGet information about our XML/RSS backend and how to use itBrowse the news archiveVisit our discussion forumVizitati forumul in limba romana



KLIP
  1. HOME
  2. SCIENCE
  3. TECHNOLOGY
  4. WEBMASTER
  5. SECURITY
  6. MICROSOFT
  7. LINUX
  8. APPLE
  9. GAMES
  10. TELECOMS
  11. REVIEWS
  12. LIFE & STYLE
  13. EDITORIALS
  14. INTERVIEWS
  15. RSS
Welcome!
Hello, Guest

Login if you have a Softpedia.com account.

Otherwise, register for one.

TIPS AND TRICKS

Automatic Text Translation with Javascript

- An example of Google AJAX language API implementation

By: Catalin Bocanu, Web News Editor

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
<html>
<head>
<title>Google AJAX Language API Usage Example</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("language", "1")
function translate() {
google.language.translate("The First Automatic Translation", "en","fr", function(output) {
alert(output.translation)
})
}
google.setOnLoadCallback(translate);
</script>
</head>
<body>
<form>
<input type="button" value="Translate"
onclick="translate()" >
</form>
</body>
</html>


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.



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
 
Comments | Link here | Subscribe
Print | Send to friend
Today's News | Yesterday's News

Search:


22nd March 2008, 13:11 GMT | Copyright (c) 2008 Softpedia | Contact:
Read by 2,748 user(s) | Rating: | 8 vote(s) so far | Cast your vote:
Automatic Text Translation with Javascript - USER OPINIONS

Comment #1 by webprogrammer on 2008-03-23, 22: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&#039;at on 2008-05-19, 06: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!


go to top


SHARE YOUR OPINION ABOUT Automatic Text Translation with Javascript

Since you are not logged on, your comments will have to be approved before being displayed.
Click here to login, or register.
Your Name:
Your Email:
Type in the result:
Your Opinion:
 


DO YOU WANT TO CONTACT US?  

If you have some comments or you want to send us some information you can send us an email directly to .
You can use the form below for the same purpose.
Your full name: (at least 3 characters)
Your email address: (at least 5 characters)
Message subject: (at least 5 characters)
Message text:
(at least 10 characters)
Type in the result:
 
 



© 2001 - 2008 Softpedia. All rights reserved.
Softpedia™ and Softpedia™ logo are registered trademarks of SoftNews NET SRL.
Copyright Information | Privacy Policy | Terms of Use | Contact Softpedia | Update your software | Archive