How To Add Google Translate Button On Your Webpage?
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:
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..

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

Output after translating into Arabic:

Recommended Posts:
- How to Add Google Charts on a Webpage?
- button tag vs input type="button" attribute
- p5.js | translate() function
- CSS | translate() Function
- How to redirect to another webpage in HTML?
- How to redirect to another webpage using JavaScript?
- HTML5 | translate Attribute
- PHP | ImagickDraw translate() Function
- Reader's View of a GeeksforGeeks webpage
- Hide the cursor in a webpage using CSS and JavaScript
- HTML | canvas translate() Method
- How to connect multiple MySQL databases on a single webpage ?
- Reading selected webpage content using Python Web Scraping
- How to check a webpage is loaded inside an iframe or into the browser window using JavaScript?
- HTML | button Tag
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : VasuJain3



