English to Hindi Translation – Google Translation API

English to Hindi Translation - Google Translation API

Nowadays English to Hindi translation is common practice. Here I am describing steps to do English to Hindi translation in your web application using Google Language Translation API.

Many tools are available online which makes easy your English to Hindi translation. At many of social medias also, people use to write in hi-English which is mostly in practice to India.

For your web application, Google also providing it’s API to convert English to Hindi in easy way. Here are  steps defined to add English -Hindi translation feature.

1. Refer Meta Tag and Google Language Translation API

The Transliterate API handles a lot of UTF-8 text and you therefore need to set the content-type of your page to UTF-8 by adding the meta tag along with script tag.

2. Add the code after the API reference

Add this code below in your head section or anywhere on the page but after the API reference.

In this snippet, we are declaring onLoad method to set the language options and put the control which will be used to take an input and translate from source language to destination Language (English to Hindi). This onLoad function is being called on load of Google API.

Save your site from spambot: Google New reCaptcha using PHP – Are you a Robot?

Also we are using txtMessage as Id of a Textarea. Here one shortcut key is defined as well, CTRL+G to change the language means English to Hindi and English to English. By default, it would be English to Hindi and if Press once CTRL+G then text would be in English only.

3. Set a Textbox for English to Hindi Translation

Use a HTML Textbox for taking input and translating its text.

So like this, It’s very easy to English to Hindi Translation using google API. This code will support to any programming language in web application.

If you found any issue in using this Google ,Language Translation API, feel free to write us as well as comment us so that we would make it more understandable for everyone.

If you like this English to Hindi Translation using Google API, please share this post on social media.

You Might Interested In