Script for q translate

时间:2019-05-25 作者:Mutekano Fabrice

想在我的网站上添加这个脚本,就在memu右侧的顶部,我该怎么做?

代码如下:

    <!-- GTranslate: https://gtranslate.io/ -->

<a href="https://jimbere.org" title="French" class="glink nturl notranslate" style="float:right;"><img src="//jimbere.org/wp-content/plugins/gtranslate/flags/24/fr.png" height="24" width="24" alt="French" /></a>
<a href="https://jimbere.org/test/news" title="English" class="glink nturl notranslate" style="float:right;margin-right:3px"><img src="//jimbere.org/test/wp-content/plugins/gtranslate/flags/24/en.png" height="24" width="24" alt="English"/></a>
<a href="https://jimbere.org/test/amayagwa" title="English" class="glink nturl notranslate" style="float:right;margin-right:3px"><img src="//jimbere.org/test/wp-content/uploads/2019/04/burundi-flag-icon-32.png " height="24" width="24" alt="Kirundi"/></a>


<a href="https://jimbere.org/amayagwa" title="English" class="glink nturl notranslate" style="float:right;margin-right:3px"><img src="//jimbere.org/test/wp-content/uploads/2019/04/burundi-flag-icon-32.png"  alt="Kirundi" / style=" position: absolute;
    width: 26px;height: 19px; margin-top: 2px;right:54px"></a>



<style type="text/css">
#goog-gt-tt {display:none !important;}
.goog-te-banner-frame {display:none !important;}
.goog-te-menu-value:hover {text-decoration:none !important;}
.goog-text-highlight {background-color:transparent !important;box-shadow:none !important;}
body {top:0 !important;}
#google_translate_element2 {display:none!important;}
</style>

<div id="google_translate_element2"></div>
<script type="text/javascript">
function googleTranslateElementInit2() {new google.translate.TranslateElement({pageLanguage: \'fr\',autoDisplay: false}, \'google_translate_element2\');}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit2"></script>


<script type="text/javascript">
function GTranslateGetCurrentLang() {var keyValue = document[\'cookie\'].match(\'(^|;) ?googtrans=([^;]*)(;|$)\');return keyValue ? keyValue[2].split(\'/\')[2] : null;}
function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent(\'on\'+event,evt)}else{var evt=document.createEvent(\'HTMLEvents\');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}
function doGTranslate(lang_pair){if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair==\'\')return;var lang=lang_pair.split(\'|\')[1];if(GTranslateGetCurrentLang() == null && lang == lang_pair.split(\'|\')[0])return;var teCombo;var sel=document.getElementsByTagName(\'select\');for(var i=0;i<sel.length;i++)if(/goog-te-combo/.test(sel[i].className)){teCombo=sel[i];break;}if(document.getElementById(\'google_translate_element2\')==null||document.getElementById(\'google_translate_element2\').innerHTML.length==0||teCombo.length==0||teCombo.innerHTML.length==0){setTimeout(function(){doGTranslate(lang_pair)},500)}else{teCombo.value=lang;GTranslateFireEvent(teCombo,\'change\');GTranslateFireEvent(teCombo,\'change\')}}
</script>

1 个回复
最合适的回答,由SO网友:Joel Garcia Nuño 整理而成

首先检查wordpress加载菜单的位置或文件头的位置。激活主题并用代码修改的php,因为有时菜单加载在标题处。

相关推荐