Categories: PHP

how to add a Google Translate button on your website

Hii, Everyone Today i am going to tell you how to add a Google Translate button on your website.

Step 1:

  Add a <div> element with the id “google_translate_element”: inside  <body> tag

<div id=”google_translate_element”></div>

Step 2:

Add a Script tag in between <head></head>

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

 

Step 3:

  also add some javascript code in your webpages.

There are 3 types of button available for the Google Translate button.

 A.  Vertically

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

 

B. Horizontal

 <script type=”text/javascript”>
                    function googleTranslateElementInit() {
                       new google.translate.TranslateElement({pageLanguage: ‘en’, layout:                              google.translate.TranslateElement.InlineLayout.HORIZONTAL}, ‘google_translate_element’);
               }
            </script>

 

 C.  Dropdown Menu, with no other text:

                  <script type=”text/javascript”>
                         function googleTranslateElementInit() {
                            new google.translate.TranslateElement({pageLanguage: ‘en’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, ‘google_translate_element’);
                                 }
                 </script>

 

And you are ready to translate the content of your page:

Basant Mallick

Basant

Recent Posts

How to Center submit button of wpForm

You must navigate to Settings » General first. Add wpf-center to the Form CSS Class…

8 months ago

How to add Marquee on any website wordpress,PHP,HTML,eBlogger ?

if you want to add marquee on any website (wordpress,PHP,HTML,Blogger). you just need to follow…

8 months ago

How to Autoplay and Loop YouTube Videos in WordPress

First Method: Use below code to play youtube video in loop and most important is…

1 year ago

How to Disable WP JSON Rest API in WordPress without plugin ?

just add below code in wordpress theme function.php file at the bottom -------------------------------------------------- Add the…

1 year ago