Google API translator. How can I translate only one DIV?

后端 未结 2 1881
灰色年华
灰色年华 2021-01-27 22:29

How can I modify this code to translate the only one container on page with id #lyrics?

相关标签:
2条回答
  • 2021-01-27 22:47

    you can add class call notranslate into the body or the meta tag of the class then add the class translate into the div whom you want to translate its poor approach but it sure do you wok e.g

    <body class="notranslate">
    
    <h1>no translate paragraph</h1>
    
    <h1 class="translate"> i want to translate the line</h1>
    </body>
    
    0 讨论(0)
  • 2021-01-27 23:10

    Solved with this function:

    function googleSectionalElementInit() {
      new google.translate.SectionalElement({
        sectionalNodeClassName: 'lyrics',
        controlNodeClassName: 'translate-lyrics',
        background: 'trasparent'
      }, 'google_sectional_element');
    }
    
    0 讨论(0)
提交回复
热议问题