谷歌翻译使用javascript英语到法语没有选择值从页面加载下拉列表

时间:2017-10-13 08:11:17

标签: javascript google-translate

我有一个英文网站,我必须将所有内容转换为法语 没有来自谷歌翻译的选择值下拉页面加载 你能救我吗?

我为此创建了一个文件,请帮助我

import Firebase

1 个答案:

答案 0 :(得分:1)

我设置法语默认

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>

<style>
#google_translate_element{width:300px;float:right;text-align:right;display:block}
.goog-te-banner-frame.skiptranslate { display: none !important;} 
body { top: 0px !important; }
#goog-gt-tt{display: none !important; top: 0px !important; } 
.goog-tooltip skiptranslate{display: none !important; top: 0px !important; } 
.activity-root { display: hide !important;} 
.status-message { display: hide !important;}
.started-activity-container { display: hide !important;}
#google_translate_element{ display: none !important;}
</style>
<div id="google_translate_element"></div>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

<script type="text/javascript">
  function googleTranslateElementInit() {
    new google.translate.TranslateElement({  

      includedLanguages: 'fr',
      layout: google.translate.TranslateElement.InlineLayout.SIMPLE
    }, 'google_translate_element');

    var lang = 'French';
    var $frame = $('.goog-te-menu-frame:first'); 
console.log($frame.contents().find('.goog-te-menu2-item span.text:contains('+lang+')').click());

  }
</script>








Why do we use it?

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).