Betolz review for G | translate

5 / 5

Oct. 21, 2021

hi, I did an adjustment for my shop (betolz.com) so that you only have 1 flag visible that switches when language changes. maybe this is an idea for a new feature :) I paste the code below... function showFlags(de, en) { document.getElementById("GTranslate_deFlag").style.display = ((de == true) ? 'none' : 'content'); document.getElementById("GTranslate_enFlag").style.display = ((en == true) ? 'none' : 'content'); } if (typeof GTranslateGetCurrentLang != "function") function GTranslateGetCurrentLang() { var keyValue = document.cookie.match("(^|;) ?googtrans=([^;]*)(;|$)"); return keyValue ? keyValue[2].split("/")[2] : null; } function gt_loadScript(url, callback) { var lang = GTranslateGetCurrentLang(); showFlags(((lang == "de" || lang == null) ? true : false), (lang == "en" ? true : false)); var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState) { script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } var gtSwitcherJS = function ($) { /*{auto_detect_code}*/ }; gt_loadScript("//code.jquery.com/jquery-1.12.4.min.js", function () { jQuery_gtranslate = jQuery.noConflict(true); gtSwitcherJS(jQuery_gtranslate); }); #goog-gt-tt { display: none !important; } .goog-te-banner-frame { display: none !important; } .goog-te-menu-value:hover { text-decoration: none !important; } body { top: 0 !important; } #google_translate_element2 { display: none !important; } function googleTranslateElementInit2() { new google.translate.TranslateElement( { pageLanguage: "de", autoDisplay: false }, "google_translate_element2" ); } if (typeof GTranslateGetCurrentLang != "function") 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]; console.log(lang); if (lang == "de") { document.getElementById("GTranslate_deFlag").style.display = "none"; document.getElementById("GTranslate_enFlag").style.display = "contents"; event.stopPropagation(); } else { document.getElementById("GTranslate_deFlag").style.display = "contents"; document.getElementById("GTranslate_enFlag").style.display = "none"; event.stopPropagation(); } if (GTranslateGetCurrentLang() == null && lang == lang_pair.split("|")[0]) return; if (typeof ga == "function") { ga( "send", "event", "GTranslate", lang, location.hostname + location.pathname + location.search ); } else { if (typeof _gaq != "undefined") _gaq.push([ "_trackEvent", "GTranslate", lang, location.hostname + location.pathname + location.search, ]); } 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]; 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"); } }

Store

Betolz

Using app

9 months

Total reviews

5

Average rating

5.0

G | translate for Shopify
G | translate
4.7 star
1,976 reviews

Translate Shopify with GTranslate

Shopify App Store