Home > other >  Google tries to translate English HTML subscripts from Arabic
Google tries to translate English HTML subscripts from Arabic

Time:02-19

I have a simple HTML page with some <sub> elements in it. For some reason, Google Translate offers to translate the subscripts from Arabic to English (despite being English to begin with), only moving them down a little when translated. The HTML page language is set to en-US. Is this just my computer being weird, or is there a code-related reason?

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <!--<meta name="google" content="notranslate"> (this successfully gets rid of the translate popup, commented out for testing purposes)-->
    <meta charset="utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
    <title>test</title>
    <link rel="icon" href="favicon.svg" type="image/svg"/>
    <link href="style.css" rel="stylesheet" type="text/css"/>
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="functions.js"></script>
    <script src="main.js" defer></script>
  </head>
  <body style="min-width: 0">
    <div id="test"></div>
  </body>
</html>

Added to #test by JS:

<div >A<sub>1</sub></div>

Website: enter image description here


If your webpage uses HTML and XML interchangably, you might need to add the following to your opening <html>-tag (see this link):

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
    ...
</html>

If your Google Translate does still pop up, you have the following options:

  1. add translate="no" to your root html-tag
  2. add the class notranslate to your root html-tag
  3. add <meta name="google" content="notranslate"> to your head-tag

Your code should look as follows:

<html lang="en" translate="no" >
    <head>
        <meta name="google" content="notranslate"/>
        ....
    </head>
    ....
</html>

CodePudding user response:

@Lawrence Cherone's comment about adding more text seems to fix the problem, as does @unknown6656's suggestion of adding <meta name="google" content="notranslate">. I still don't know why subscripts are considered Arabic text, but adding English text seems to fix the problem. Thanks for all the answers.

  • Related