Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How To Add Google Translate Button On Your Webpage?

  • Difficulty Level : Medium
  • Last Updated : 07 Aug, 2019

Google Translate is a free multilingual machine translation service developed by Google, to translate text from one language into another. It offers a website interface, mobile apps for Android and iOS, and an API that helps developers build browser extensions and software applications. Google Translate supports over 100 languages at various levels.

Follow the steps to add a google translate button on your website:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Step 1: Start with a basic web page and add a “div” element.
In the code below a “div” element with the id “google_translate_element” is created.

Step 2: Add google translate api reference.

Step 3: Add Javascript function..


<!DOCTYPE html> 
<html lang="en-US"
        How To Add Google Translate
        Button On Your Webpage ?
    <p>Hello everyone!</p
    <p>Welcome to GeeksforGeeks</p
        Translate this page in
        your preferred language:
    <div id="google_translate_element"></div
    <script type="text/javascript"
        function googleTranslateElementInit() { 
            new google.translate.TranslateElement(
                {pageLanguage: 'en'}, 
    <script type="text/javascript" src=
        You can translate the content of this
        page by selecting a language in the
        select box.


Output after translating into Arabic:

My Personal Notes arrow_drop_up
Recommended Articles
Page :