Adding Google Translate to a web site

前端 未结 13 2012
忘掉有多难
忘掉有多难 2020-12-01 07:17

Looking here Google Translate I get the following code.



        
相关标签:
13条回答
  • 2020-12-01 07:21

    Use:

    c._ctkk=eval('((function(){var a\x3d2143197373;var b\x3d-58933561;return 408631+\x27.\x27+(a+b)})())');
    
    <script type="text/javascript"> 
        (function(){
            var d="text/javascript",e="text/css",f="stylesheet",g="script",h="link",k="head",l="complete",m="UTF-8",n=".";
            function p(b){
                var a=document.getElementsByTagName(k)[0];
                a||(a=document.body.parentNode.appendChild(document.createElement(k)));
                a.appendChild(b)}
            function _loadJs(b){
                var a=document.createElement(g);
                a.type=d;
                a.charset=m;
                a.src=b;
                p(a)}
            function _loadCss(b){
                var a=document.createElement(h);
                a.type=e;
                a.rel=f;
                a.charset=m;
                a.href=b;
                p(a)}
            function _isNS(b){
                b=b.split(n);
                for(var a=window,c=0;c<b.length;++c)
                    if(!(a=a[b[c]])) return ! 1;
                return ! 0}
            function _setupNS(b){
                b=b.split(n);
                for(var a=window,c=0;c<b.length;++c)
                    a.hasOwnProperty?a.hasOwnProperty(b[c])?a=a[b[c]]:a=a[b[c]]={}:a=a[b[c]]||(a[b[c]]={});
                return a}
            window.addEventListener&&"undefined"==typeof document.readyState&&window.addEventListener("DOMContentLoaded",function(){document.readyState=l},!1);
        if (_isNS('google.translate.Element')){return}
        (function(){
            var c=_setupNS('google.translate._const');
            c._cl='en';
            c._cuc='googleTranslateElementInit1';
            c._cac='';
            c._cam='';
            c._ctkk=eval('((function(){var a\x3d2143197373;var b\x3d-58933561;return 408631+\x27.\x27+(a+b)})())');
            var h='translate.googleapis.com';
            var s=(true?'https':window.location.protocol=='https:'?'https':'http')+'://';
            var b=s+h;
            c._pah=h;
            c._pas=s;
            c._pbi=b+'/translate_static/img/te_bk.gif';
            c._pci=b+'/translate_static/img/te_ctrl3.gif';
            c._pli=b+'/translate_static/img/loading.gif';
            c._plla=h+'/translate_a/l';
            c._pmi=b+'/translate_static/img/mini_google.png';
            c._ps=b+'/translate_static/css/translateelement.css';
            c._puh='translate.google.com';
            _loadCss(c._ps);
            _loadJs(b+'/translate_static/js/element/main.js');
        })();
        })();
    </script> 
    
    0 讨论(0)
  • 2020-12-01 07:22
    <div id="google_translate_element"></div><script type="text/javascript">
    function googleTranslateElementInit() {
      new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'ar', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
    }
    </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    
    0 讨论(0)
  • 2020-12-01 07:22
    <div id="google_translate_element"></div><script type="text/javascript">
    function googleTranslateElementInit() {
      new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'ar', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
    }
    </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    
    0 讨论(0)
  • 2020-12-01 07:23
    <div id="google_translate_element"></div><script type="text/javascript">
    function googleTranslateElementInit() {
      new google.translate.TranslateElement({pageLanguage: 'fr', layout: google.translate.TranslateElement.FloatPosition.TOP_RIGHT}, 'google_translate_element');
    }
    </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    
    0 讨论(0)
  • 2020-12-01 07:24
    {{-- Google Language Translator  START --}}
    <style>
    .google-translate {
        display: inline-block;
        vertical-align: top;
        padding-top: 15px;
    }
    
    .goog-logo-link {
        display: none !important;
    }
    
    .goog-te-gadget {
        color: transparent !important;
    }
    
    #google_translate_element {
        display: none;
    }
    
    .goog-te-banner-frame.skiptranslate {
        display: none !important;
    }
    
    body {
        top: 0px !important;
    }
    
    </style>
    
    <script src="{{asset('js/translate-google.js')}}"></script>
    
    
    
    <script type="text/javascript">
    function googleTranslateElementInit2(){
        new google.translate.TranslateElement({
                        pageLanguage:'en',
                        includedLanguages: 'en,es',
            // https://ctrlq.org/code/19899-google-translate-languages
            // includedLanguages: 'en,it,la,fr',
            // layout:     google.translate.TranslateElement.InlineLayout.SIMPLE,
            autoDisplay:true
        },'google_translate_element2');
        var a = document.querySelector("#google_translate_element select");
        // console.log(a);
    
        if(a){
            a.selectedIndex=1;
            a.dispatchEvent(new Event('change'));
        }
    }
    </script>
    
    <ul class="navbar-nav my-lg-0 m-r-10">
    <li>
        <div class="google-translate">
            <div id="google_translate_element2"></div>
        </div>
    </li>
    

    {{-- Google Language Translator ENDS --}}

    // translate-google.js
    (function () {
    var gtConstEvalStartTime = new Date();
    
    function d(b) {
        var a = document.getElementsByTagName("head")[0];
        a || (a = document.body.parentNode.appendChild(document.createElement("head")));
        a.appendChild(b)
    }
    
    function _loadJs(b) {
        // console.log(b);
        var a = document.createElement("script");
        a.type = "text/javascript";
        a.charset = "UTF-8";
        a.src = b;
        d(a)
    }
    
    function _loadCss(b) {
        var a = document.createElement("link");
        a.type = "text/css";
        a.rel = "stylesheet";
        a.charset = "UTF-8";
        a.href = b;
        d(a)
    }
    
    function _isNS(b) {
        b = b.split(".");
        for (var a = window, c = 0; c < b.length; ++c)
            if (!(a = a[b[c]])) return !1;
        return !0
    }
    
    function _setupNS(b) {
        b = b.split(".");
        for (var a = window, c = 0; c < b.length; ++c) a.hasOwnProperty ? a.hasOwnProperty(b[c]) ? a = a[b[c]] : a = a[b[c]] = {} : a = a[b[c]] || (a[b[c]] = {});
        return a
    }
    window.addEventListener && "undefined" == typeof document.readyState && window.addEventListener("DOMContentLoaded", function () {
        document.readyState = "complete"
    }, !1);
    if (_isNS('google.translate.Element')) {
        return
    }(function () {
        var c = _setupNS('google.translate._const');
        c._cest = gtConstEvalStartTime;
        gtConstEvalStartTime = undefined;
        c._cl = 'en';
        c._cuc = 'googleTranslateElementInit2';
        c._cac = '';
        c._cam = '';
        c._ctkk = eval('((function(){var a\x3d3002255536;var b\x3d-2533142796;return 425386+\x27.\x27+(a+b)})())');
        var h = 'translate.googleapis.com';
        var s = (true ? 'https' : window.location.protocol == 'https:' ? 'https' : 'http') + '://';
        var b = s + h;
        c._pah = h;
        c._pas = s;
        c._pbi = b + '/translate_static/img/te_bk.gif';
        c._pci = b + '/translate_static/img/te_ctrl3.gif';
        c._pli = b + '/translate_static/img/loading.gif';
        c._plla = h + '/translate_a/l';
        c._pmi = b + '/translate_static/img/mini_google.png';
        c._ps = b + '/translate_static/css/translateelement.css';
        c._puh = 'translate.google.com';
        _loadCss(c._ps);
        _loadJs(b + '/translate_static/js/element/main.js');
    })();
    })();
    
    0 讨论(0)
  • 2020-12-01 07:34
    <div id="google_translate_element"></div><script type="text/javascript">
    function googleTranslateElementInit() {
      new google.translate.TranslateElement({pageLanguage: 'ko', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
    }
    </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    
    0 讨论(0)
提交回复
热议问题