Book Image

PHP Ajax Cookbook

Book Image

PHP Ajax Cookbook

Overview of this book

Table of Contents (16 chapters)
PHP Ajax Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Translating text using Google Ajax API


In this section, we will look at the Google Ajax API to translate text from one language to other languages. Google provides Ajax APIs for a large set of operations, like for Google Map, language translation, charts, and so on. In this part, we will look at how to use Google translate Ajax API to translate text from one language to another language.

Getting ready

To use the Google Ajax API, we first need to sign up the key for your particular domain. You can get the API key for Google Ajax API form this URL: http://code.google.com/apis/loader/signup.html. After getting the API key, you can insert the Google API with the following URL:

<script type="text/javascript" src="https://www.google.com/jsapi?key=YOUR-API-KEY"></script>

Now, after calling the URL, we can load the particular module for the application. Let's say we're going to use the Ajax language API; then we can load it like this:

google.load("language", "1");

where the first parameter...