2017-10-13 64 views
0

我有一個網站的英文,我必須將所有內容轉換爲法文 與選擇值從谷歌翻譯下拉頁面加載 你能幫我。谷歌翻譯使用JavaScript的英文到法文沒有選擇從下拉頁面加載價值

我創建一個文件爲請幫我

<div id="google_translate_element"></div> 
<script type="text/javascript"> 
function googleTranslateElementInit() { 
    new google.translate.TranslateElement({pageLanguage: 'en', layout: 
    google.translate.TranslateElement.FloatPosition.TOP_LEFT}, 'google_translate_element'); 
    } 
</script> 
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></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). 
+0

測試配售'<腳本類型= 「文/ JavaScript的」 SRC =「//翻譯。 google.cn/translate_a/element.js?cb=googleTranslateElementInit「> '在您的'googleTranslateElementInit'函數聲明之前 – GGO

回答

0

我設置法語默認

<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).