1/*!*************************************************** 2 * google-translate.js v1.0.6 3 * https://Get-Web.Site/ 4 * author: Vitalii P. 5 *****************************************************/ 6 7 8/* ÐÑ Ð¼Ð¾Ð¶ÐµÑе пеÑенеÑÑи даннÑй конÑиг в head Ñвоего ÑайÑа, ÑÑÐ¾Ð±Ñ Ð´Ð¸Ð½Ð°Ð¼Ð¸ÑеÑки конÑигÑÑиÑоваÑÑ Ð·Ð½Ð°ÑÐµÐ½Ð¸Ñ Ð¿Ñи помоÑи даннÑÑ Ð¸Ð· CMS */ 9/* You can transfer this config to the head of your site to dynamically configure values using data from the CMS */ 10 11 12const googleTranslateConfig = { 13 /* Original language */ 14 lang: "ru", 15 16 /* ÐÑли Ñ Ð¾ÑиÑе подпиÑаÑÑÑÑ Ð½Ð° ÑобÑÑие "FinishTranslate" (ÐÐ¾Ð¼ÐµÐ½Ñ ÐºÐ¾Ð³Ð´Ð° ÑкÑÐ¸Ð¿Ñ Ð·Ð°ÐºÐ¾Ð½Ñил пеÑевод), ÑаÑÑкоменÑиÑÑйÑе и добавÑÑе лÑбое пÑовеÑоÑное Ñлово на оÑигиналÑном ÑзÑке */ 17 /* If you want to subscribe to the "FinishTranslate" event (The moment when the script finished translating), uncomment and add any test word in the original language */ 18 // testWord: "ЯзÑк", 19 20 /* The language we translate into on the first visit*/ 21 /* ЯзÑк, на коÑоÑÑй пеÑеводим пÑи пеÑвом поÑеÑении */ 22 // langFirstVisit: 'en', 23 24 /* ÐÑли ÑкÑÐ¸Ð¿Ñ Ð½Ðµ ÑабоÑÐ°ÐµÑ Ð¸Ð»Ð¸ ÑабоÑÐ°ÐµÑ Ð½ÐµÐ¿ÑавилÑно, ÑаÑкомменÑиÑÑйÑе и ÑкажиÑе оÑновной домен в ÑвойÑÑве domain */ 25 /* If the script does not work or does not work correctly, uncomment and specify the main domain in the domain property */ 26 // domain: "Get-Web.Site" 27 28}; 29 30$(function () { 31 /* ÐодклÑÑаем Ð²Ð¸Ð´Ð¶ÐµÑ google translate */ 32 /* Connecting the google translate widget */ 33 let script = document.createElement("script"); 34 script.src = `//translate.google.com/translate_a/element.js?cb=TranslateWidgetIsLoaded`; 35 document.getElementsByTagName("head")[0].appendChild(script); 36}); 37 38function TranslateWidgetIsLoaded() { 39 TranslateInit(googleTranslateConfig); 40} 41 42function TranslateInit(config) { 43 if (config.langFirstVisit && !$.cookie("googtrans")) { 44 /* ÐÑли ÑÑÑановлен ÑзÑк пеÑевода Ð´Ð»Ñ Ð¿ÐµÑвого поÑеÑÐµÐ½Ð¸Ñ Ð¸ кÑки не назнаÑÐµÐ½Ñ */ 45 /* If the translation language is installed for the first visit and cookies are not assigned */ 46 TranslateCookieHandler("/auto/" + config.langFirstVisit); 47 } 48 49 let code = TranslateGetCode(config); 50 51 TranslateHtmlHandler(code); 52 53 if (code == config.lang) { 54 /* ÐÑли ÑзÑк по ÑмолÑаниÑ, ÑÐ¾Ð²Ð¿Ð°Ð´Ð°ÐµÑ Ñ ÑзÑком на коÑоÑÑй пеÑеводим, Ñо оÑиÑаем кÑки */ 55 /* If the default language is the same as the language we are translating into, then we clear the cookies */ 56 TranslateCookieHandler(null, config.domain); 57 } 58 59 if (config.testWord) TranslateMutationObserver(config.testWord, code == config.lang); 60 61 62 /* ÐниÑиализиÑÑем Ð²Ð¸Ð´Ð¶ÐµÑ Ñ ÑзÑком по ÑмолÑÐ°Ð½Ð¸Ñ */ 63 /* Initialize the widget with the default language */ 64 new google.translate.TranslateElement({ 65 pageLanguage: config.lang, 66 multilanguagePage: true, // Your page contains content in more than one languages 67 }); 68 69 /* ÐеÑаем ÑобÑÑие клик на Ñлаги */ 70 /* Assigning a handler to the flags */ 71 $("[data-google-lang]").click(function () { 72 TranslateCookieHandler( 73 "/auto/" + $(this).attr("data-google-lang"), 74 config.domain 75 ); 76 /* ÐеÑезагÑÑжаем ÑÑÑаниÑÑ */ 77 /* Reloading the page */ 78 window.location.reload(); 79 }); 80} 81 82function TranslateGetCode(config) { 83 /* ÐÑли кÑки неÑ, Ñо пеÑедаем деÑолÑнÑй ÑзÑк */ 84 /* If there are no cookies, then we pass the default language */ 85 let lang = 86 $.cookie("googtrans") != undefined && $.cookie("googtrans") != "null" 87 ? $.cookie("googtrans") 88 : config.lang; 89 return lang.match(/(?!^\/)[^\/]*$/gm)[0]; 90} 91 92function TranslateCookieHandler(val, domain) { 93 /* ÐапиÑÑваем кÑки /ÑзÑк_коÑоÑÑй_пеÑеводим/ÑзÑк_на_коÑоÑÑй_пеÑеводим */ 94 /* Writing down cookies /language_for_translation/the_language_we_are_translating_into */ 95 $.cookie("googtrans", val, { 96 domain: document.domain, 97 path: '/' 98 }); 99 $.cookie("googtrans", val, { 100 domain: "." + document.domain, 101 path: '/' 102 }); 103 104 if (domain == "undefined") return; 105 /* запиÑÑваем кÑки Ð´Ð»Ñ Ð´Ð¾Ð¼ÐµÐ½Ð°, еÑли он назнаÑен в конÑиге */ 106 /* Writing down cookies for the domain, if it is assigned in the config */ 107 $.cookie("googtrans", val, { 108 domain: domain, 109 path: '/' 110 }); 111 112 $.cookie("googtrans", val, { 113 domain: "." + domain, 114 path: '/' 115 }); 116} 117 118function TranslateHtmlHandler(code) { 119 /* ÐолÑÑаем ÑзÑк на коÑоÑÑй пеÑеводим и пÑоизводим Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ñе манипÑлÑÑии Ñ DOM */ 120 /* We get the language to which we translate and produce the necessary manipulations with DOM */ 121 $('[data-google-lang="' + code + '"]').addClass("language__img_active"); 122} 123 124 125function TranslateMutationObserver(word, isOrigin) { 126 127 if (isOrigin) { 128 document.dispatchEvent(new CustomEvent("FinishTranslate")); 129 } else { 130 131 /* Создаем ÑкÑÑÑÑй блок в коÑоÑÑй добавлÑем ÑеÑÑовое Ñлово на оÑигиналÑном ÑзÑке. ÐÑо Ð¿Ð¾Ð·Ð²Ð¾Ð»Ð¸Ñ Ð½Ð°Ð¼ оÑÑледиÑÑ Ð¼Ð¾Ð¼ÐµÐ½Ñ ÐºÐ¾Ð³Ð´Ð° ÑÐ°Ð¹Ñ Ð±ÑÐ´ÐµÑ Ð¿ÐµÑеведен и вÑзваÑÑ ÑобÑÑие "FinishTranslate" */
132 /* Creating a hidden block in which we add a test word in the original language. This will allow us to track the moment when the site is translated and trigger the "FinishTranslate" event */ 133 134 let div = document.createElement('div'); 135 div.id = 'googleTranslateTestWord'; 136 div.innerHTML = word; 137 div.style.display = 'none'; 138 document.body.prepend(div); 139 140 let observer = new MutationObserver(() => { 141 document.dispatchEvent(new CustomEvent("FinishTranslate")); 142 observer.disconnect(); 143 }); 144 145 observer.observe(div, { 146 childList: false, 147 subtree: true, 148 characterDataOldValue: true 149 }); 150 } 151}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.