Google Translate

We have a few sites at work that has Google Translate at the top of the site which enables people to view the site in different languages. Of course, we also have a disclaimer that the translation may or may not be accurate. Is there a way for me to add the following lines of of Javascript easily in Plone to enable the following:
https://www.w3schools.com/howto/howto_google_translate.asp

Basically, it is possible to add the following scripts to Plone? If so how and where can I do so?

<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="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Any advice would be most appreciated. Thank you so much.

I hack the main_template.pt to do this kind of stuff.

Although easy, it's really not the right answer.

The "Right" way is to add it to your resource registry - even Through The Web:
https://training.plone.org/5/javascript/index.html
https://training.plone.org/5/javascript/exercises/1.html

I would do

  1. If it is a diazo theme: add it to index.html (or whatever file defined in rules.xml

or

  1. Add a viewlet

I dont think editing main_template is a good idea (it might give you problems later in life )

It does if you're not careful. I don't recommend it either.

I think the header viewlet is the way to go. https://docs.plone.org/develop/plone/views/viewlets.html#head-viewlets