The basic idea that you need to add cookies that google translate looks for when it's loading the element, and then you can even hide google translate elements using CSS.
Here is a short example using js.cookie:
<div class="custom-translate" st yle="display: none;" id="google_translate_element"></div>
<!-- ASYNCHRONOUS Google Translate -->
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
layout: google.translate.TranslateElement.FloatPosition.TOP_RIGHT,
autoDisplay: false
}, 'google_translate_element');
}
(function () {
var googleTranslateScript = document.createElement('script');
googleTranslateScript.type = 'text/javascript';
googleTranslateScript.async = true;
googleTranslateScript.src =
'//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(
googleTranslateScript);
})();
Cookies.set('GoogleAccountsLocale_session', 'iw', { expires: 999});
Cookies.set('googtrans', '/en/iw', { expires: 999});
</script>
CSS to hide the google translate elements:
<style>
.goog-te-banner-frame,.custom-translate {
display: none;
}
body {
top: 0 !important;
}
.goog-tooltip {
display: none !important;
}
.goog-tooltip:hover {
display: none !important;
}
.goog-text-highlight {
background-color: transparent !important;
border: none !important;
box-shadow: none !important;
}
</style>