skip to Main Content

Is it possible to set the translation a browser might use for various bits of a web page?

For instance, the page is all in English and the label of a button might be “Submit” and the user might want to translate that page in Spanish using the built-in browser translator. How do I force the browser to keep the button’s label in English while translating the rest of the page in Spanish?

2

Answers


  1. It is not possible to prevent the translation of individual elements. When user will translate page using browser it will translate the whole page and we there is now way to avoid translation of a perticular element or in your case button.

    Edit: Alternatively you can use an image as the button instead of text. By using an image, text in the image will not be translated by browser
    Here is code to explain what I am trying to say

    <!DOCTYPE html>
    <html>
    <head>
      <style>
        .image-button {
          width: 200px; 
          height: 200px; 
          
        }
      </style>
    </head>
    <body>
        hola este es un texto de muestra
      <img src="https://www.transparentpng.com/thumb/click-here-button/Gaezhb-click-here-button-images-png.png" alt="Button" class="image-button" onclick="buttonClick()" />
      
      <script>
        function buttonClick() {
          
          alert("Button clicked!");
        }
      </script>
    </body>
    </html>
     
    

    Try running this in your browser.

    Login or Signup to reply.
  2. Don’t take this answer too seriously, but you might be able to break your text into pieces that cannot be translated on its own. No guarantees that this will work though:

    <html>
    <body>
      <button>
        s<span></span>u<span>b</span>m<span>i<span>t</span></span>
      </button>
    </body>
    </html>

    Additionally, this might break all other kinds of behavior/functionality of your browser or screen readers. If visitors want to have your site translated, let them.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search