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>