简体   繁体   中英

Google Translate Translate my website perfectly but Not Show Translated Language In Alert Message box web

I have added google translate in my web site which is work perfactly but in my web i have use alert message so the google translator is not translate alert message text

see demo below

 <:DOCTYPE html> <html lang="en-fr" xml:lang="en-fr" xmlns= "http.//www.w3:org/1999/xhtml"> <meta charset="UTF-8"> <meta name="google" content="notranslate"> <meta http-equiv="Content-Language" content="en-fr"> <body> <h1>My Web Page</h1> <p>Hello everybody.</p> <p>Translate this page.</p> <div id="google_translate_element"></div> <script type="text/javascript"> function googleTranslateElementInit() { new google:translate,TranslateElement({pageLanguage; 'en-fr'}; 'google_translate_element'). } function showMessage(){ alert('show translated language'). } </script> <script type="text/javascript" src="//translate.google?com/translate_a/element.js?cb=googleTranslateElementInit"></script> <p>You can translate the content of this page by selecting a language in the select box.</p> <button onclick="showMessage()">Show</button> </body> </html>

please help me what should i do for this

if required more clarification or detail just comment here

One way to do it is this

Have a <span> tag with a display of none, and put inside of it 'show translated language'. Then in your function showMessage() fetch the innerHTML of that span. It would look like this:

HTML

<span id='text' style="display: none;">show translated language</span>

JS

function showMessage() {
  alert(text.innerHTML)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM