Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks

Quickly add Google translate widget button to any website

Aman Jain, January 10, 2022November 12, 2023

Google translator is most popular translation engine to translate any word into any language. Translation of complete website can be a hectic task to developer but using the Google translation we can easily translate complete website into any language.

By adding the Google translate widget to website it increase the SEO visibility and as well reader preferred language.

We can integrate Google translation easily through the quick simple steps as below

Step 1 : Create a webpage

First step to create a simple website index.html or use any existing page.

<!DOCTYPE html>
<html>
<body>

<h1>Readerstacks.com Google Translate example</h1>

  <div id="google_translate_button"></div>
  <p>This is a dummy text to translate into any language</p>
</body>
<html>

As you can see we added simple html to page and a div with id google_translate_button to add the Google translation button to it.

Step 2 : Add translation javascript

Now add JavaScript script to page

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

We also added googleTranslateInit as a callback function to init our function on load.

Step 3 : Initialize Google translation

After adding the JavaScript element.js of translation we need to initialize it as below

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

So complete html and JavaScript

<!DOCTYPE html>
<html>
<body>

<h1>Readerstacks.com Google Translate example</h1>

  <div id="google_translate_button"></div>

  <p>This is a dummy text to translate into any language</p>
</body>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateInit"></script>
<script type="text/javascript">
    function googleTranslateInit() {
      new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_button');
    }
</script>
<html>

Live Preview : https://stackblitz.com/edit/web-platform-uldq2v

Related

Uncategorized

Post navigation

Previous post
Next post

Related Posts

Uncategorized rollback specific migration in laravel

How to rollback specific migration in laravel ?

March 6, 2022February 8, 2024

In this article we will learn rollback specific migration in laravel, in our recent article i wrote about creating migration in laravel and sometimes after creating migration we want to rollback specific migration laravel so in this article i will show you to rollback a specific migration in laravel. Laravel…

Read More

What is httpd.conf and httpd-vhost.conf file in apache?

August 28, 2021August 28, 2021

https.conf is main file of apache web server to handle the requests. Apache httpd.conf file generally located at /etc/httpd/conf/httpd, /etc/apache2/ , /etc/apache2/sites-enabled/ in ubuntu. httpd.conf contains the information of server root and port used routing. httpd-vhost contains additional information of virtual host.

Read More
Uncategorized Request Method

Difference between $_POST $_GET and $_REQUEST in PHP

August 19, 2021November 8, 2023

PHP gives there is 3 types of request methods to by which client can send information to server. In this article we will learn difference in get vs post and also in request. So, Methods are as follow 1. $_POST Request Method $_POST is used to fetch the post request…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Transformative Power of Education in the Digital Age
  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version