I have successfully created a custom Google Translate dropdown that allows a user to switch languages. This also hides the Google Translate top bar and tool tips.
My problem:
everything seems to work 100% in Preview except that it starts in Spanish rather than English
when I check the live site, switching languages in the dropdown does nothing except append the URL - e.g. …/#googtrans(en|es)
I believe the script is directing to the link before translation process occurs, you can check this script out and see if this works for your project. You can check this cloneable first for testing purposes and implement it or take inspiration from it if it solves the use-case.
@AJ_Dev this solution works great and so easy to implement! It works perfectly on my published site but my only issue is on the WF Preview of the site. In Preview the site defaults to Spanish even if I switch back to English it jumps back to Spanish. Any ideas why this might be happening?
I don’t usually test custom code in preview mode, since there might be some issues due to caching / scripts not executing etc. But, if it works in published site for the projects, I believe it is good to go.
And also when I do enable the custom code for your site on preview mode, by default I am able to see the site in English language:
Thanks @AJ_Dev ! I’m sure it’s probably a caching issue in Preview—and as you say, better to test custom code in live environment.
Thanks again for sharing this solution! I’ve been fighting with this using a few different solutions offered by others, but yours was easy to implement and worked first time!