How to switch off automatic translation

Did you know that web browsers translate your app into your users’ native languages?

This has two problems:

  1. The Quill Editor (Anvil Extras) does not work with translation.
  2. The translations are terrible and make your app look bad.

I have chosen to switch it off completely and rather make the necessary languages available in the app myself.

This is how I did it (thank you @stucork for helping me):

from anvil.js import get_dom_node
from anvil.js.window import jQuery, document

# Inside the constructor of your main app:
dom_node = document.getElementsByTagName('html')[0]
dom_node.setAttribute("lang", "notranslate")
dom_node.classList.add("notranslate")

#Add this in 'Native Libraries' 
#(it is possible this is no longer needed, but I keep it in to be on the safe side)

<meta name="google" content="notranslate" />

Note: I did not manage to disable translation just for the Quill by wrapping a div class=“notranslate” around it. It worked for some but not all webbrowser/translator settings.

2 Likes