Automatic language translation of webpageHow do I redirect to another webpage?Is JavaScript a pass-by-reference or pass-by-value language?Why page is shown after POST request?Usage of charset in the script tag for JavascriptJcarousel not rendering slidesPrettyphoto - how to pass unique parameter to the callback functionScroll Automatically to the Bottom of the Pagexing / wysihtml5 unescapes < and >XMLHttpRequest error with Google translate (No 'Access-Control-Allow-Origin' header)Cannot display HTML string

Teleport everything in a large zone; or teleport all living things and make a lot of equipment disappear

How does doing something together work?

Bit one of the Intel 8080's Flags register

Madrid to London w/ Expired 90/180 days stay as US citizen

Is there a generally agreed upon solution to Bradley's Infinite Regress without appeal to Paraconsistent Logic?

Other than good shoes and a stick, what are some ways to preserve your knees on long hikes?

What is a "major country" as named in Bernie Sanders' Healthcare debate answers?

Output Distinct Factor Cuboids

Pronunciation of "солнце"

Is it appropriate to CC a lot of people on an email?

How to ensure that neurotic or annoying characters don't get tiring on the long run

How To Make Earth's Oceans as Brackish as Lyr's

What organs or modifications would be needed for a life biological creature not to require sleep?

What did the first ever Hunger Games look like?

Who are the people reviewing far more papers than they're submitting for review?

What does "boys rule, girls drool" mean?

Unpredictability of Stock Market

Why my Render has black outlines?

Is it safe to unplug a blinking USB drive after 'safely' ejecting it?

Are there any “Third Order” acronyms used in space exploration?

What is the word for a person who destroys monuments?

Exam design: give maximum score per question or not?

How to generate short fixed length cryptographic hashs?

Can a business put whatever they want into a contract?



Automatic language translation of webpage


How do I redirect to another webpage?Is JavaScript a pass-by-reference or pass-by-value language?Why page is shown after POST request?Usage of charset in the script tag for JavascriptJcarousel not rendering slidesPrettyphoto - how to pass unique parameter to the callback functionScroll Automatically to the Bottom of the Pagexing / wysihtml5 unescapes < and >XMLHttpRequest error with Google translate (No 'Access-Control-Allow-Origin' header)Cannot display HTML string






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I found this code here on stackoverflow







<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Test Google translate</title>
<style>
.skiptranslate,
#google_translate_element
display: none;


body
min-height: 0px !important;
position: static !important;
top: 0px !important;

</style>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</head>

<body>
The text is translated using Google translate.
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit()
$.when(
new google.translate.TranslateElement(
pageLanguage: 'en',
includedLanguages: 'es',
layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
, 'google_translate_element')
).done(function()
var select = document.getElementsByClassName('goog-te-combo')[0];
select.selectedIndex = 1;
select.addEventListener('click', function()
select.dispatchEvent(new Event('change'));
);
select.click();
);

</script>
</body>

</html>






I want to ask that how can I automatically translate the webpage to a specific language when loaded. The above code does not work. Is there any way?










share|improve this question
































    -1















    I found this code here on stackoverflow







    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <title>Test Google translate</title>
    <style>
    .skiptranslate,
    #google_translate_element
    display: none;


    body
    min-height: 0px !important;
    position: static !important;
    top: 0px !important;

    </style>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
    <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    </head>

    <body>
    The text is translated using Google translate.
    <div id="google_translate_element"></div>
    <script type="text/javascript">
    function googleTranslateElementInit()
    $.when(
    new google.translate.TranslateElement(
    pageLanguage: 'en',
    includedLanguages: 'es',
    layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
    , 'google_translate_element')
    ).done(function()
    var select = document.getElementsByClassName('goog-te-combo')[0];
    select.selectedIndex = 1;
    select.addEventListener('click', function()
    select.dispatchEvent(new Event('change'));
    );
    select.click();
    );

    </script>
    </body>

    </html>






    I want to ask that how can I automatically translate the webpage to a specific language when loaded. The above code does not work. Is there any way?










    share|improve this question




























      -1












      -1








      -1








      I found this code here on stackoverflow







      <!DOCTYPE html>
      <html lang="en">

      <head>
      <meta charset="UTF-8">
      <title>Test Google translate</title>
      <style>
      .skiptranslate,
      #google_translate_element
      display: none;


      body
      min-height: 0px !important;
      position: static !important;
      top: 0px !important;

      </style>
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
      <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
      </head>

      <body>
      The text is translated using Google translate.
      <div id="google_translate_element"></div>
      <script type="text/javascript">
      function googleTranslateElementInit()
      $.when(
      new google.translate.TranslateElement(
      pageLanguage: 'en',
      includedLanguages: 'es',
      layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
      , 'google_translate_element')
      ).done(function()
      var select = document.getElementsByClassName('goog-te-combo')[0];
      select.selectedIndex = 1;
      select.addEventListener('click', function()
      select.dispatchEvent(new Event('change'));
      );
      select.click();
      );

      </script>
      </body>

      </html>






      I want to ask that how can I automatically translate the webpage to a specific language when loaded. The above code does not work. Is there any way?










      share|improve this question
















      I found this code here on stackoverflow







      <!DOCTYPE html>
      <html lang="en">

      <head>
      <meta charset="UTF-8">
      <title>Test Google translate</title>
      <style>
      .skiptranslate,
      #google_translate_element
      display: none;


      body
      min-height: 0px !important;
      position: static !important;
      top: 0px !important;

      </style>
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
      <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
      </head>

      <body>
      The text is translated using Google translate.
      <div id="google_translate_element"></div>
      <script type="text/javascript">
      function googleTranslateElementInit()
      $.when(
      new google.translate.TranslateElement(
      pageLanguage: 'en',
      includedLanguages: 'es',
      layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
      , 'google_translate_element')
      ).done(function()
      var select = document.getElementsByClassName('goog-te-combo')[0];
      select.selectedIndex = 1;
      select.addEventListener('click', function()
      select.dispatchEvent(new Event('change'));
      );
      select.click();
      );

      </script>
      </body>

      </html>






      I want to ask that how can I automatically translate the webpage to a specific language when loaded. The above code does not work. Is there any way?






      <!DOCTYPE html>
      <html lang="en">

      <head>
      <meta charset="UTF-8">
      <title>Test Google translate</title>
      <style>
      .skiptranslate,
      #google_translate_element
      display: none;


      body
      min-height: 0px !important;
      position: static !important;
      top: 0px !important;

      </style>
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
      <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
      </head>

      <body>
      The text is translated using Google translate.
      <div id="google_translate_element"></div>
      <script type="text/javascript">
      function googleTranslateElementInit()
      $.when(
      new google.translate.TranslateElement(
      pageLanguage: 'en',
      includedLanguages: 'es',
      layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
      , 'google_translate_element')
      ).done(function()
      var select = document.getElementsByClassName('goog-te-combo')[0];
      select.selectedIndex = 1;
      select.addEventListener('click', function()
      select.dispatchEvent(new Event('change'));
      );
      select.click();
      );

      </script>
      </body>

      </html>





      <!DOCTYPE html>
      <html lang="en">

      <head>
      <meta charset="UTF-8">
      <title>Test Google translate</title>
      <style>
      .skiptranslate,
      #google_translate_element
      display: none;


      body
      min-height: 0px !important;
      position: static !important;
      top: 0px !important;

      </style>
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
      <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
      </head>

      <body>
      The text is translated using Google translate.
      <div id="google_translate_element"></div>
      <script type="text/javascript">
      function googleTranslateElementInit()
      $.when(
      new google.translate.TranslateElement(
      pageLanguage: 'en',
      includedLanguages: 'es',
      layout: google.translate.TranslateElement.FloatPosition.TOP_LEFT
      , 'google_translate_element')
      ).done(function()
      var select = document.getElementsByClassName('goog-te-combo')[0];
      select.selectedIndex = 1;
      select.addEventListener('click', function()
      select.dispatchEvent(new Event('change'));
      );
      select.click();
      );

      </script>
      </body>

      </html>






      javascript jquery html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 12:56









      VLAZ

      8,0095 gold badges25 silver badges38 bronze badges




      8,0095 gold badges25 silver badges38 bronze badges










      asked Mar 28 at 12:54









      parezapareza

      13 bronze badges




      13 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          The code in your question works (with some extra remarks below), provided that you take the following snippet out of the code:



          <style>
          .skiptranslate, #google_translate_element display: none;
          body min-height: 0px !important; position: static !important; top: 0px !important;
          </style>


          https://jsfiddle.net/q6L75dor/ This produces the following result:



          Works



          It did however fail sometimes because I got warnings about Cross-Origin Read Blocking in the Chrome Dev tools:



          Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtsqm3f5 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.



          So you might have to look into that more thoroughly before using in a production environment.
          Also, sometimes it ran automatically, and sometimes it only worked after I clicked the dropdown manually (notice that in the code it attaches a click handler to the dropdown list), so this may be related to loading times or something, but again, this might be something worth looking into as well.






          share|improve this answer

























          • Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

            – pareza
            Mar 28 at 15:09










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398197%2fautomatic-language-translation-of-webpage%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          The code in your question works (with some extra remarks below), provided that you take the following snippet out of the code:



          <style>
          .skiptranslate, #google_translate_element display: none;
          body min-height: 0px !important; position: static !important; top: 0px !important;
          </style>


          https://jsfiddle.net/q6L75dor/ This produces the following result:



          Works



          It did however fail sometimes because I got warnings about Cross-Origin Read Blocking in the Chrome Dev tools:



          Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtsqm3f5 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.



          So you might have to look into that more thoroughly before using in a production environment.
          Also, sometimes it ran automatically, and sometimes it only worked after I clicked the dropdown manually (notice that in the code it attaches a click handler to the dropdown list), so this may be related to loading times or something, but again, this might be something worth looking into as well.






          share|improve this answer

























          • Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

            – pareza
            Mar 28 at 15:09















          0
















          The code in your question works (with some extra remarks below), provided that you take the following snippet out of the code:



          <style>
          .skiptranslate, #google_translate_element display: none;
          body min-height: 0px !important; position: static !important; top: 0px !important;
          </style>


          https://jsfiddle.net/q6L75dor/ This produces the following result:



          Works



          It did however fail sometimes because I got warnings about Cross-Origin Read Blocking in the Chrome Dev tools:



          Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtsqm3f5 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.



          So you might have to look into that more thoroughly before using in a production environment.
          Also, sometimes it ran automatically, and sometimes it only worked after I clicked the dropdown manually (notice that in the code it attaches a click handler to the dropdown list), so this may be related to loading times or something, but again, this might be something worth looking into as well.






          share|improve this answer

























          • Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

            – pareza
            Mar 28 at 15:09













          0














          0










          0









          The code in your question works (with some extra remarks below), provided that you take the following snippet out of the code:



          <style>
          .skiptranslate, #google_translate_element display: none;
          body min-height: 0px !important; position: static !important; top: 0px !important;
          </style>


          https://jsfiddle.net/q6L75dor/ This produces the following result:



          Works



          It did however fail sometimes because I got warnings about Cross-Origin Read Blocking in the Chrome Dev tools:



          Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtsqm3f5 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.



          So you might have to look into that more thoroughly before using in a production environment.
          Also, sometimes it ran automatically, and sometimes it only worked after I clicked the dropdown manually (notice that in the code it attaches a click handler to the dropdown list), so this may be related to loading times or something, but again, this might be something worth looking into as well.






          share|improve this answer













          The code in your question works (with some extra remarks below), provided that you take the following snippet out of the code:



          <style>
          .skiptranslate, #google_translate_element display: none;
          body min-height: 0px !important; position: static !important; top: 0px !important;
          </style>


          https://jsfiddle.net/q6L75dor/ This produces the following result:



          Works



          It did however fail sometimes because I got warnings about Cross-Origin Read Blocking in the Chrome Dev tools:



          Cross-Origin Read Blocking (CORB) blocked cross-origin response https://translate.googleapis.com/translate_a/l?client=te&alpha=true&hl=en&cb=_callbacks____0jtsqm3f5 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.



          So you might have to look into that more thoroughly before using in a production environment.
          Also, sometimes it ran automatically, and sometimes it only worked after I clicked the dropdown manually (notice that in the code it attaches a click handler to the dropdown list), so this may be related to loading times or something, but again, this might be something worth looking into as well.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 14:49









          Thomas MulderThomas Mulder

          3505 silver badges20 bronze badges




          3505 silver badges20 bronze badges















          • Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

            – pareza
            Mar 28 at 15:09

















          • Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

            – pareza
            Mar 28 at 15:09
















          Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

          – pareza
          Mar 28 at 15:09





          Actually I dont want to show the languages list on the page. So thats why the style code is there. This should be automatic translation of the page to given language like spanish in the code.

          – pareza
          Mar 28 at 15:09








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398197%2fautomatic-language-translation-of-webpage%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해