Add google translate button to your site
Saw the translate button for the first time in this site - https://srghma.github.io/.
Thought it is super cool. Wanted to add it to my site as well.
Google translate will only keep improving, to be able to have my site in any language the reader wants - is also invaluable.
Asked the author of the site how he did it, he referred me here - https://www.geeksforgeeks.org/add-google-translate-button-webpage/
And this is my implementation google-translate.js
:
function googleTranslateElementInit() { new google.translate.TranslateElement( { pageLanguage: 'en' }, 'google_translate_element' ); } const script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'; document.head.appendChild(script);
Added a piece in html:
<div id="google_translate_element" style="float:right;"></div>"
And it works! Cool!