Google Translate

  1. Google Translate Spanish
  2. Google Translate English To Tagalog
  3. Google Translate English To Spanish
  4. Google Translator

Google Translate also offers both webmasters and their readers a way to translate documents hosted on a website. For example, if you need to translate this PDF file into Spanish, go to translate.google.com and enter the file's URL into the left-hand textbox, then choose 'Spanish' as the target language on the right. Service: translate.googleapis.com. To call this service, we recommend that you use the Google-provided client libraries. If your application needs to use your own libraries to call this service, use the following information when you make the API requests. Discovery document.

Google uses cookies and data to:
  • Deliver and maintain services, like tracking outages and protecting against spam, fraud, and abuse
  • Measure audience engagement and site statistics to understand how our services are used
If you agree, we’ll also use cookies and data to:
  • Improve the quality of our services and develop new ones
  • Deliver and measure the effectiveness of ads
  • Show personalized content, depending on your settings
  • Show personalized or generic ads, depending on your settings, on Google and across the web
For non-personalized content and ads, what you see may be influenced by things like the content you’re currently viewing and your location (ad serving is based on general location). Personalized content and ads can be based on those things and your activity like Google searches and videos you watch on YouTube. Personalized content and ads include things like more relevant results and recommendations, a customized YouTube homepage, and ads that are tailored to your interests.

Click “Customize” to review options, including controls to reject the use of cookies for personalization and information about browser-level controls to reject some or all cookies for other uses. You can also visit g.co/privacytools anytime.

Home » How to » How to add google translate to your website

Google Translate is a free multilingual machine translation service. It can translate the Website's text content from one language to another. It offers a huge list of languages to translate and has an efficient, reliable and easy way to translate the webpage in whatever language the user wants. It supports over 100 languages. Use this website translator to convert webpages into your choice of language.

So, How to add Google Translate Button on a website?

To directly translate your documents, you can go to https://translate.google.com/. But to add it on your website, you need to add Google Translate Script on the webpage

To use google translate script, you need to import google api containing googleTranslateElementInit() function with new google.translate.TranslateElement() and google_translate_element id.

We will use a CDN path, provided by Google, to implement the google translator. Just follow the whole tutorial to earn how to add google translate ( translate google com ). You can download complete html code of examples from Try-it Editor.

Google Translate Button

We will implement it in a simple web page, but you can make a beautiful design and then place the translator button properly.

Google Translate implementation will need three steps:

  • Set up CDN Path for Google API.
  • Set up a div element to place Translator.
  • Set up Default Language for the Webpage.

Let's implement all the steps:

Step 1: Set the CDN path to Google Translate API. This CDN will only work if you have an active internet connection otherwise not. This path will add the script of Translator on your page.


<script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'> </script>

Step 2: Add a <div> element with id=google_translate_element. It is a predefined id in google's script. This div element will be used by the Translator API to give the user a list of languages.


<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <title> Google Translate </title> </head> <body> <h1>Your Website Heading</h1> <div></div> </body> </html>

Step 3: Add Script to choose default language of the webpage. Every language has a unique code in Translator; you can check the list from here. We have selected American English as default, and the code is 'en'.


<script type='text/javascript'> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script>

Now, add all these together. You are ready to use the Translator. Go to the Try-it editor to see the results. You can also download the full code from the Editor. Click on Try This Code.

Google Translate Spanish


<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <title> Google Translater for Website </title> </head> <body> <h2>Your Web Page</h2> <p>Click on the dropdown button to translate.</p> <p>Translate this page:</p> <div></div> <script type='text/javascript'> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script> <script type='text/javascript' src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'></script> <p>You can translate the content of this page by selecting a language in the select box.</p> </body> </html>

Output

Google Translater for Website

Your Web Page

Google Translate English To Tagalog

Translate

Google Translate English To Spanish

Click on the dropdown button to translate.

Translate this page:

Google Translator

You can translate the content of this page by selecting a language in the select box.