Automatic Translate Addon For Loco Translate - Version 2.1.3

Version Description

Download this release

Release Info

Developer Narinder singh
Plugin Icon 128x128 Automatic Translate Addon For Loco Translate
Version 2.1.3
Comparing to
See all releases

Code changes from version 2.1.2 to 2.1.3

assets/js/custom.js CHANGED
@@ -391,7 +391,7 @@
391
 
392
  $("html").addClass("merge-translations");
393
  var checkModal = setInterval(function() {
394
- if ($('.loco-modal #loco-apis-batch').length && String($(".loco-modal").attr("style")).indexOf("block") > -1) {
395
  $("html").removeClass("merge-translations");
396
  $("select#auto-api").hide();
397
  $("#loco-apis-batch a.icon-help").hide();
@@ -420,7 +420,8 @@
420
  $("button.icon-robot[data-loco='auto']").on("click", function(e) {
421
  if (e.originalEvent !== undefined) {
422
  var checkModal = setInterval(function() {
423
- if ($('.loco-modal #loco-apis-batch').length && String($(".loco-modal").attr("style")).indexOf("block") > -1) {
 
424
  $(".loco-modal").removeClass("addtranslations");
425
  $("select#auto-api").show();
426
  $("#loco-apis-batch a.icon-help").show(); //Show help button again.
391
 
392
  $("html").addClass("merge-translations");
393
  var checkModal = setInterval(function() {
394
+ if ($('.loco-modal #loco-apis-batch').length || String($(".loco-modal").attr("style")).indexOf("none") <= -1) {
395
  $("html").removeClass("merge-translations");
396
  $("select#auto-api").hide();
397
  $("#loco-apis-batch a.icon-help").hide();
420
  $("button.icon-robot[data-loco='auto']").on("click", function(e) {
421
  if (e.originalEvent !== undefined) {
422
  var checkModal = setInterval(function() {
423
+ //if ($('.loco-modal #loco-apis-batch').length || String($(".loco-modal").attr("style")).indexOf("block") > -1) {
424
+ if ($('.loco-modal #loco-apis-batch').length && String($(".loco-modal").attr("style")).indexOf("none") <= -1){
425
  $(".loco-modal").removeClass("addtranslations");
426
  $("select#auto-api").show();
427
  $("#loco-apis-batch a.icon-help").show(); //Show help button again.
assets/js/custom.min.js CHANGED
@@ -1 +1 @@
1
- !function(window,$){if(null!=window.locoConf){var locoConf=window.locoConf;if(null!=locoConf.conf){var allStrings=locoConf.conf.podata;allStrings.shift();var ajaxUrl=extradata.ajax_url,nonces=extradata.nonce,locale=locoConf.conf.locale,projectId="";projectId=null!=locoConf.conf.project?locoConf.conf.project.domain+"-"+locale.lang+"_"+locale.region:"temp-"+locale.lang+"_"+locale.region,newaddAutoTranslationBtn(),settingsModel(),createStringsPopup()}}function newaddAutoTranslationBtn(){$("#loco-editor nav").find("#cool-auto-translate-btn").length>0&&$("#loco-editor nav").find("#cool-auto-translate-btn").remove();const locoActions=$("#loco-editor nav").find("#loco-actions"),proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(proActiveBtn)}function createPopup(){$("#atlt-dialog").dialog({resizable:!1,height:"auto",width:400,modal:!0,buttons:{Cancel:function(){$(this).dialog("close")}}})}$("#cool-auto-translate-btn").on("click",(function(){createPopup()}));var encodeHtmlEntity=function(str){for(var buf=[],i=str.length-1;i>=0;i--)buf.unshift(["&#",str[i].charCodeAt(),";"].join(""));return buf.join("")};function printStringsInPopup(jsonObj,type){var html="",totalTChars=0,index=1;if(jsonObj){for(const key in jsonObj)if(jsonObj.hasOwnProperty(key)){const element=jsonObj[key];if(""!=element.source){if("yandex"==type)html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source" >'+encodeHtmlEntity(element.source)+"</td>";else{if(key>2500)break;html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+"</td>"}html+="yandex"==type?'<td translate="yes" class="target translate">'+element.source+"</td></tr>":'<td class="target translate"></td></tr>',index++,totalTChars+=element.source.length}}$(".ytstats").each((function(){$(this).find(".totalChars").html(totalTChars)}))}"yandex"==type&&$("#yandex_string_tbl").html(html)}var gModal=document.getElementById("atlt_strings_model");function settingsModel(){let ytPreviewImg,gtPreviewImg,dplPreviewImg,modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt-dialog" title="Step 1 - Select Translation Provider" style="display:none;">\n <div class="atlt-settings">\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Yandex Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_yandex_transate_btn" class="notranslate button button-primary">Yandex Translate</button>\n <span class="proonly-button alsofree">✔ Available</span>\n <br/><a href="https://translate.yandex.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.yt_preview}" alt="powered by Yandex Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_gtranslate_btn" disabled="disabled" class="notranslate button button-primary">Google Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://translate.google.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.gt_preview}" alt="powered by Google Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Deepl Doc Translator</strong>\n <div class="inputGroup">\n <button disabled="disabled" id="atlt_deepl_btn" class="notranslate button button-primary">DeepL Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://www.deepl.com/en/translator" target="_blank"><img style="margin-top: 5px;" src="${extradata.dpl_preview}" alt="powered by DeepL Translate"></a>\n <br/>DeepL translation is better than Google, Microsoft & other auto-translation providers - <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank">read review by techcruch</a>\n </div>\n <hr/>\n \n <ul style="margin: 0;">\n <li><span style="color:green">✔</span> Unlimited Translations<br/>(<span style="font-size: 11px;color: #248e09;">*DeepL provides limited no. of free doc translations daily</span>)</li>\n <li><span style="color:green">✔</span> No API Key Required</li>\n <li><span style="color:green">✔</span> Check Languages Support - <a href="https://yandex.com/support/translate/supported-langs.html" target="_blank">Yandex</a>, <a href="https://en.wikipedia.org/wiki/Google_Translate#Supported_languages" target="_blank">Google</a>, <a href="https://www.deepl.com/en/translator" target="_blank">DeepL</a></li>\n </ul>\n \n </div>\n </div>\n `;$("body").append(modelHTML)}function createStringsPopup(){let modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt_strings_model" class="modal atlt_custom_model">\n \x3c!-- Modal content --\x3e\n <div class="modal-content">\n <input type="hidden" id="project_id" value="${projectId}">\n <div class="modal-header">\n <span class="close ">&times;</span>\n <h2 class="notranslate">Step 2 - Start Automatic Translation Process</h2>\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n \n <div style="display:none" class="ytstats hidden">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"> </strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n \n </div>\n <div class="notice inline notice-info is-dismissible">Plugin will not translate any strings with HTML or special characters because Yandex Translator currently\n does not support HTML and special characters translations. \n You can edit translated strings inside Loco Translate Editor after merging the translations. Only special chracters (%s, %d) fixed at the time of merging of the translations.</div>\n <div class="notice inline notice-info is-dismissible">Machine translations are not 100% correct.\n Please verify strings before using on production website.</div>\n <div class="modal-body">\n <div class="my_translate_progress">Automatic translation is in progress....<br/>It will take few minutes, enjoy ☕ coffee in this time!<br/><br/>Please do not leave this window or browser tab while translation is in progress...</div>\n <h3 class="choose-lang">Choose language <span class="dashicons-before dashicons-translation"></span></h3>\n <div id="ytWidget">..Loading</div>\n <br/>\n <div class="string_container"> \n <table class="scrolldown" id="stringTemplate">\n <thead>\n <th class="notranslate">S.No</th>\n <th class="notranslate">Source Text</th>\n <th class="notranslate">Translation</th>\n </thead>\n <tbody id="yandex_string_tbl">\n </tbody>\n </table>\n </div>\n <div class="notice-container"></div>\n </div>\n <div class="modal-footer">\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n <div style="display:none" class="ytstats">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"></strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n </div>\n </div>\n </div>`;$("body").append(modelHTML)}function saveTranslatedStrings(translatedObj,projectId){if(void 0!==translatedObj&&translatedObj.length)if(translatedObj.length<5e3&&translatedObj.length>=2500){var firstPart=translatedObj.slice(0,2500),secondPart=translatedObj.slice(2500);sendRequest(firstPart,projectId,part="first"),sendRequest(secondPart,projectId,part="second")}else if(translatedObj.length>=5e3){var firstPart=translatedObj.slice(0,2500),secondPart=translatedObj.slice(2500,5e3),thirdpart=translatedObj.slice(5e3);sendRequest(firstPart,projectId,part="first"),sendRequest(secondPart,projectId,part="second"),sendRequest(thirdpart,projectId,part="third")}else sendRequest(translatedObj,projectId,part="one")}function sendRequest(stringData,projectId,part){var data={action:"save_translations",data:JSON.stringify(stringData),part:part,"project-id":projectId};jQuery.post(ajaxUrl,data,(function(response){$("#loco-editor nav").find("button").each((function(i,el){var id;"auto"==el.getAttribute("data-loco")&&$(el).trigger("click")}))}))}window.onclick=function(event){event.target==gModal&&(gModal.style.display="none")},$("#atlt_strings_model").find(".close").on("click",(function(){$("#atlt_strings_model").fadeOut("slow")})),$("#atlt_yandex_transate_btn").on("click",(function(){var defaultcode=locale.lang?locale.lang:null,arr;switch(defaultcode){case"bel":defaultlang="be";break;case"he":defaultlang="iw";break;case"snd":defaultlang="sd";break;case"jv":defaultlang="jv";break;case"nb":case"nn":defaultlang="no";break;default:defaultlang=defaultcode}$(".save_it").prop("disabled",!0),$(".ytstats").css("display","none"),localStorage.setItem("lang",defaultlang),["af","jv","no","am","ar","az","ba","be","bg","bn","bs","ca","ceb","cs","cy","da","de","el","en","eo","es","et","eu","fa","fi","fr","ga","gd","gl","gu","he","hi","hr","ht","hu","hy","id","is","it","ja","jv","ka","kk","km","kn","ko","ky","la","lb","lo","lt","lv","mg","mhr","mi","mk","ml","mn","mr","mrj","ms","mt","my","ne","nl","no","pa","pap","pl","pt","ro","ru","si","sk","sl","sq","sr","su","sv","sw","ta","te","tg","th","tl","tr","tt","udm","uk","ur","uz","vi","xh","yi","zh"].includes(defaultlang)||($(".notice-container").addClass("notice inline notice-warning").html("Yandex Automatic Translator Does not support this language."),$(".string_container").hide(),$(".choose-lang").hide(),$(".save_it").hide(),$("#ytWidget").hide());var plainStrArr=filterRawObject(allStrings,"plain");plainStrArr.length>0?printStringsInPopup(plainStrArr,type="yandex"):($("#ytWidget").hide(),$(".notice-container").addClass("notice inline notice-warning").html("There is no plain string available for translations."),$(".string_container").hide(),$(".choose-lang").hide(),$(".save_it").hide()),$("#atlt-dialog").dialog("close"),$("#atlt_strings_model").addClass("yandex-translator").fadeIn("slow")}));var rpl={'"% s"':'"%s"','"% d"':'"%d"','"% S"':'"%s"','"% D"':'"%d"',"% s":" %s ","% S":" %s ","% d":" %d ","% D":" %d ","٪ s":" %s ","٪ S":" %s ","٪ d":" %d ","٪ D":" %d ","٪ س":" %s "};function filterRawObject(rawArray,filterType){return filterdArr=[],filterdArr=rawArray.filter((item,index)=>{if(""!==item.source&&void 0!==item.source&&(void 0===item.target||""==item.target))return!ValidURL(item.source)&&(!isHTML(item.source)&&(!!isPlacehodersChars(item.source)||!isSpecialChars(item.source)&&(!isEmoji(item.source)&&!item.source.includes("#"))))})}function ValidURL(str){var pattern;return!!/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(str)}function isHTML(str){var rgex;return void 0!==str&&/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i.test(str)}function isSpecialChars(str){var rgex;return void 0!==str&&/[@^{}|<>]/g.test(str)}function isEmoji(str){var ranges=["(?:[✀-➿]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[#-9]️?⃣|㊙|㊗|〽|〰|Ⓜ|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|🆎|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|🈚|🈯|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|‼|⁉|[▪-▫]|▶|◀|[◻-◾]|©|®|™|ℹ|🀄|[☀-⛿]|⬅|⬆|⬇|⬛|⬜|⭐|⭕|⌚|⌛|⌨|⏏|[⏩-⏳]|[⏸-⏺]|🃏|⤴|⤵|[←-⇿])"];return!!str.match(ranges.join("|"))}function isPlacehodersChars(str){var rgex;return void 0!==str&&/%s|%d/g.test(str)}function strtr(s,p,r){return!!s&&{2:function(){for(var i in p)s=strtr(s,i,p[i]);return s},3:function(){return s.replace(RegExp(p,"g"),r)},0:function(){}}[arguments.length]()}$(".save_it").on("click",(function(){var translatedObj=[];$("#stringTemplate tbody tr").each((function(index){var index=$(this).find("td.source").text(),target=$(this).find("td.target").text(),source=$(this).find("td.source").text(),improvedTarget=strtr(target,rpl),improvedSource=strtr(source,rpl);translatedObj.push({source:improvedSource,target:improvedTarget})}));var projectId=$(this).parents("#atlt_strings_model").find("#project_id").val();saveTranslatedStrings(translatedObj,projectId);var translatedObj=[];$(".atlt_custom_model").fadeOut("slow"),$("html").addClass("merge-translations");var checkModal=setInterval((function(){$(".loco-modal #loco-apis-batch").length&&String($(".loco-modal").attr("style")).indexOf("block")>-1&&($("html").removeClass("merge-translations"),$("select#auto-api").hide(),$("#loco-apis-batch a.icon-help").hide(),$("#loco-apis-batch a.icon-group").hide(),$("#loco-apis-batch #loco-job-progress").hide(),$("select#auto-api option[value='loco_auto']").prop("selected","selected"),$("select#auto-api").val($("select#auto-api option[value='loco_auto']").val()),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Step 3 - Add Translations into Editor and Save"),$("#loco-apis-batch button.button-primary span").html("Start Adding Process"),$("#loco-apis-batch button.button-primary").on("click",(function(){$(this).find("span").html("Adding...")})),$(".loco-modal").addClass("addtranslations"),$(".noapiadded").remove(),$(".loco-modal #loco-apis-batch form").show(),$(".loco-modal #loco-apis-batch").removeClass("loco-alert"),clearInterval(checkModal))}),100)})),$("button.icon-robot[data-loco='auto']").on("click",(function(e){if(void 0!==e.originalEvent)var checkModal=setInterval((function(){if($(".loco-modal #loco-apis-batch").length&&String($(".loco-modal").attr("style")).indexOf("block")>-1){$(".loco-modal").removeClass("addtranslations"),$("select#auto-api").show(),$("#loco-apis-batch a.icon-help").show(),$("#loco-apis-batch a.icon-group").show(),$("#loco-apis-batch #loco-job-progress").show(),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Auto-translate this file"),$("#loco-apis-batch button.button-primary span").html("Translate");var opt=0;$("select#auto-api option").each((function(){opt+=1})),1==opt&&($(".noapiadded").remove(),$(".loco-modal #loco-apis-batch").removeClass("loco-alert"),$(".loco-modal #loco-apis-batch form").hide(),$(".loco-modal #loco-apis-batch").addClass("loco-alert"),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("No translation APIs configured"),$(".loco-modal #loco-apis-batch").append("<div class='noapiadded'><p>Add automatic translation services in the plugin settings.<br>or<br>Use <strong>Auto Translate</strong> addon button.</p><nav><a href='http://locotranslate.local/wp-admin/admin.php?page=loco-config&amp;action=apis' class='button button-link has-icon icon-cog'>Settings</a><a href='https://localise.biz/wordpress/plugin/manual/providers' class='button button-link has-icon icon-help' target='_blank'>Help</a><a href='https://localise.biz/wordpress/translation?l=de-DE' class='button button-link has-icon icon-group' target='_blank'>Need a human?</a></nav></div>")),clearInterval(checkModal)}}),100)}))}(window,jQuery);
1
+ !function(window,$){if(null!=window.locoConf){var locoConf=window.locoConf;if(null!=locoConf.conf){var allStrings=locoConf.conf.podata;allStrings.shift();var ajaxUrl=extradata.ajax_url,nonces=extradata.nonce,locale=locoConf.conf.locale,projectId="";projectId=null!=locoConf.conf.project?locoConf.conf.project.domain+"-"+locale.lang+"_"+locale.region:"temp-"+locale.lang+"_"+locale.region,newaddAutoTranslationBtn(),settingsModel(),createStringsPopup()}}function newaddAutoTranslationBtn(){$("#loco-editor nav").find("#cool-auto-translate-btn").length>0&&$("#loco-editor nav").find("#cool-auto-translate-btn").remove();const locoActions=$("#loco-editor nav").find("#loco-actions"),proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(proActiveBtn)}function createPopup(){$("#atlt-dialog").dialog({resizable:!1,height:"auto",width:400,modal:!0,buttons:{Cancel:function(){$(this).dialog("close")}}})}$("#cool-auto-translate-btn").on("click",(function(){createPopup()}));var encodeHtmlEntity=function(str){for(var buf=[],i=str.length-1;i>=0;i--)buf.unshift(["&#",str[i].charCodeAt(),";"].join(""));return buf.join("")};function printStringsInPopup(jsonObj,type){var html="",totalTChars=0,index=1;if(jsonObj){for(const key in jsonObj)if(jsonObj.hasOwnProperty(key)){const element=jsonObj[key];if(""!=element.source){if("yandex"==type)html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source" >'+encodeHtmlEntity(element.source)+"</td>";else{if(key>2500)break;html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+"</td>"}html+="yandex"==type?'<td translate="yes" class="target translate">'+element.source+"</td></tr>":'<td class="target translate"></td></tr>',index++,totalTChars+=element.source.length}}$(".ytstats").each((function(){$(this).find(".totalChars").html(totalTChars)}))}"yandex"==type&&$("#yandex_string_tbl").html(html)}var gModal=document.getElementById("atlt_strings_model");function settingsModel(){let ytPreviewImg,gtPreviewImg,dplPreviewImg,modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt-dialog" title="Step 1 - Select Translation Provider" style="display:none;">\n <div class="atlt-settings">\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Yandex Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_yandex_transate_btn" class="notranslate button button-primary">Yandex Translate</button>\n <span class="proonly-button alsofree">✔ Available</span>\n <br/><a href="https://translate.yandex.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.yt_preview}" alt="powered by Yandex Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_gtranslate_btn" disabled="disabled" class="notranslate button button-primary">Google Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://translate.google.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.gt_preview}" alt="powered by Google Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Deepl Doc Translator</strong>\n <div class="inputGroup">\n <button disabled="disabled" id="atlt_deepl_btn" class="notranslate button button-primary">DeepL Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://www.deepl.com/en/translator" target="_blank"><img style="margin-top: 5px;" src="${extradata.dpl_preview}" alt="powered by DeepL Translate"></a>\n <br/>DeepL translation is better than Google, Microsoft & other auto-translation providers - <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank">read review by techcruch</a>\n </div>\n <hr/>\n \n <ul style="margin: 0;">\n <li><span style="color:green">✔</span> Unlimited Translations<br/>(<span style="font-size: 11px;color: #248e09;">*DeepL provides limited no. of free doc translations daily</span>)</li>\n <li><span style="color:green">✔</span> No API Key Required</li>\n <li><span style="color:green">✔</span> Check Languages Support - <a href="https://yandex.com/support/translate/supported-langs.html" target="_blank">Yandex</a>, <a href="https://en.wikipedia.org/wiki/Google_Translate#Supported_languages" target="_blank">Google</a>, <a href="https://www.deepl.com/en/translator" target="_blank">DeepL</a></li>\n </ul>\n \n </div>\n </div>\n `;$("body").append(modelHTML)}function createStringsPopup(){let modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt_strings_model" class="modal atlt_custom_model">\n \x3c!-- Modal content --\x3e\n <div class="modal-content">\n <input type="hidden" id="project_id" value="${projectId}">\n <div class="modal-header">\n <span class="close ">&times;</span>\n <h2 class="notranslate">Step 2 - Start Automatic Translation Process</h2>\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n \n <div style="display:none" class="ytstats hidden">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"> </strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n \n </div>\n <div class="notice inline notice-info is-dismissible">Plugin will not translate any strings with HTML or special characters because Yandex Translator currently\n does not support HTML and special characters translations. \n You can edit translated strings inside Loco Translate Editor after merging the translations. Only special chracters (%s, %d) fixed at the time of merging of the translations.</div>\n <div class="notice inline notice-info is-dismissible">Machine translations are not 100% correct.\n Please verify strings before using on production website.</div>\n <div class="modal-body">\n <div class="my_translate_progress">Automatic translation is in progress....<br/>It will take few minutes, enjoy ☕ coffee in this time!<br/><br/>Please do not leave this window or browser tab while translation is in progress...</div>\n <h3 class="choose-lang">Choose language <span class="dashicons-before dashicons-translation"></span></h3>\n <div id="ytWidget">..Loading</div>\n <br/>\n <div class="string_container"> \n <table class="scrolldown" id="stringTemplate">\n <thead>\n <th class="notranslate">S.No</th>\n <th class="notranslate">Source Text</th>\n <th class="notranslate">Translation</th>\n </thead>\n <tbody id="yandex_string_tbl">\n </tbody>\n </table>\n </div>\n <div class="notice-container"></div>\n </div>\n <div class="modal-footer">\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n <div style="display:none" class="ytstats">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"></strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n </div>\n </div>\n </div>`;$("body").append(modelHTML)}function saveTranslatedStrings(translatedObj,projectId){if(void 0!==translatedObj&&translatedObj.length)if(translatedObj.length<5e3&&translatedObj.length>=2500){var firstPart=translatedObj.slice(0,2500),secondPart=translatedObj.slice(2500);sendRequest(firstPart,projectId,part="first"),sendRequest(secondPart,projectId,part="second")}else if(translatedObj.length>=5e3){var firstPart=translatedObj.slice(0,2500),secondPart=translatedObj.slice(2500,5e3),thirdpart=translatedObj.slice(5e3);sendRequest(firstPart,projectId,part="first"),sendRequest(secondPart,projectId,part="second"),sendRequest(thirdpart,projectId,part="third")}else sendRequest(translatedObj,projectId,part="one")}function sendRequest(stringData,projectId,part){var data={action:"save_translations",data:JSON.stringify(stringData),part:part,"project-id":projectId};jQuery.post(ajaxUrl,data,(function(response){$("#loco-editor nav").find("button").each((function(i,el){var id;"auto"==el.getAttribute("data-loco")&&$(el).trigger("click")}))}))}window.onclick=function(event){event.target==gModal&&(gModal.style.display="none")},$("#atlt_strings_model").find(".close").on("click",(function(){$("#atlt_strings_model").fadeOut("slow")})),$("#atlt_yandex_transate_btn").on("click",(function(){var defaultcode=locale.lang?locale.lang:null,arr;switch(defaultcode){case"bel":defaultlang="be";break;case"he":defaultlang="iw";break;case"snd":defaultlang="sd";break;case"jv":defaultlang="jv";break;case"nb":case"nn":defaultlang="no";break;default:defaultlang=defaultcode}$(".save_it").prop("disabled",!0),$(".ytstats").css("display","none"),localStorage.setItem("lang",defaultlang),["af","jv","no","am","ar","az","ba","be","bg","bn","bs","ca","ceb","cs","cy","da","de","el","en","eo","es","et","eu","fa","fi","fr","ga","gd","gl","gu","he","hi","hr","ht","hu","hy","id","is","it","ja","jv","ka","kk","km","kn","ko","ky","la","lb","lo","lt","lv","mg","mhr","mi","mk","ml","mn","mr","mrj","ms","mt","my","ne","nl","no","pa","pap","pl","pt","ro","ru","si","sk","sl","sq","sr","su","sv","sw","ta","te","tg","th","tl","tr","tt","udm","uk","ur","uz","vi","xh","yi","zh"].includes(defaultlang)||($(".notice-container").addClass("notice inline notice-warning").html("Yandex Automatic Translator Does not support this language."),$(".string_container").hide(),$(".choose-lang").hide(),$(".save_it").hide(),$("#ytWidget").hide());var plainStrArr=filterRawObject(allStrings,"plain");plainStrArr.length>0?printStringsInPopup(plainStrArr,type="yandex"):($("#ytWidget").hide(),$(".notice-container").addClass("notice inline notice-warning").html("There is no plain string available for translations."),$(".string_container").hide(),$(".choose-lang").hide(),$(".save_it").hide()),$("#atlt-dialog").dialog("close"),$("#atlt_strings_model").addClass("yandex-translator").fadeIn("slow")}));var rpl={'"% s"':'"%s"','"% d"':'"%d"','"% S"':'"%s"','"% D"':'"%d"',"% s":" %s ","% S":" %s ","% d":" %d ","% D":" %d ","٪ s":" %s ","٪ S":" %s ","٪ d":" %d ","٪ D":" %d ","٪ س":" %s "};function filterRawObject(rawArray,filterType){return filterdArr=[],filterdArr=rawArray.filter((item,index)=>{if(""!==item.source&&void 0!==item.source&&(void 0===item.target||""==item.target))return!ValidURL(item.source)&&(!isHTML(item.source)&&(!!isPlacehodersChars(item.source)||!isSpecialChars(item.source)&&(!isEmoji(item.source)&&!item.source.includes("#"))))})}function ValidURL(str){var pattern;return!!/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(str)}function isHTML(str){var rgex;return void 0!==str&&/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i.test(str)}function isSpecialChars(str){var rgex;return void 0!==str&&/[@^{}|<>]/g.test(str)}function isEmoji(str){var ranges=["(?:[✀-➿]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[#-9]️?⃣|㊙|㊗|〽|〰|Ⓜ|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|🆎|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|🈚|🈯|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|‼|⁉|[▪-▫]|▶|◀|[◻-◾]|©|®|™|ℹ|🀄|[☀-⛿]|⬅|⬆|⬇|⬛|⬜|⭐|⭕|⌚|⌛|⌨|⏏|[⏩-⏳]|[⏸-⏺]|🃏|⤴|⤵|[←-⇿])"];return!!str.match(ranges.join("|"))}function isPlacehodersChars(str){var rgex;return void 0!==str&&/%s|%d/g.test(str)}function strtr(s,p,r){return!!s&&{2:function(){for(var i in p)s=strtr(s,i,p[i]);return s},3:function(){return s.replace(RegExp(p,"g"),r)},0:function(){}}[arguments.length]()}$(".save_it").on("click",(function(){var translatedObj=[];$("#stringTemplate tbody tr").each((function(index){var index=$(this).find("td.source").text(),target=$(this).find("td.target").text(),source=$(this).find("td.source").text(),improvedTarget=strtr(target,rpl),improvedSource=strtr(source,rpl);translatedObj.push({source:improvedSource,target:improvedTarget})}));var projectId=$(this).parents("#atlt_strings_model").find("#project_id").val();saveTranslatedStrings(translatedObj,projectId);var translatedObj=[];$(".atlt_custom_model").fadeOut("slow"),$("html").addClass("merge-translations");var checkModal=setInterval((function(){($(".loco-modal #loco-apis-batch").length||String($(".loco-modal").attr("style")).indexOf("none")<=-1)&&($("html").removeClass("merge-translations"),$("select#auto-api").hide(),$("#loco-apis-batch a.icon-help").hide(),$("#loco-apis-batch a.icon-group").hide(),$("#loco-apis-batch #loco-job-progress").hide(),$("select#auto-api option[value='loco_auto']").prop("selected","selected"),$("select#auto-api").val($("select#auto-api option[value='loco_auto']").val()),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Step 3 - Add Translations into Editor and Save"),$("#loco-apis-batch button.button-primary span").html("Start Adding Process"),$("#loco-apis-batch button.button-primary").on("click",(function(){$(this).find("span").html("Adding...")})),$(".loco-modal").addClass("addtranslations"),$(".noapiadded").remove(),$(".loco-modal #loco-apis-batch form").show(),$(".loco-modal #loco-apis-batch").removeClass("loco-alert"),clearInterval(checkModal))}),100)})),$("button.icon-robot[data-loco='auto']").on("click",(function(e){if(void 0!==e.originalEvent)var checkModal=setInterval((function(){if($(".loco-modal #loco-apis-batch").length&&String($(".loco-modal").attr("style")).indexOf("none")<=-1){$(".loco-modal").removeClass("addtranslations"),$("select#auto-api").show(),$("#loco-apis-batch a.icon-help").show(),$("#loco-apis-batch a.icon-group").show(),$("#loco-apis-batch #loco-job-progress").show(),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Auto-translate this file"),$("#loco-apis-batch button.button-primary span").html("Translate");var opt=0;$("select#auto-api option").each((function(){opt+=1})),1==opt&&($(".noapiadded").remove(),$(".loco-modal #loco-apis-batch").removeClass("loco-alert"),$(".loco-modal #loco-apis-batch form").hide(),$(".loco-modal #loco-apis-batch").addClass("loco-alert"),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("No translation APIs configured"),$(".loco-modal #loco-apis-batch").append("<div class='noapiadded'><p>Add automatic translation services in the plugin settings.<br>or<br>Use <strong>Auto Translate</strong> addon button.</p><nav><a href='http://locotranslate.local/wp-admin/admin.php?page=loco-config&amp;action=apis' class='button button-link has-icon icon-cog'>Settings</a><a href='https://localise.biz/wordpress/plugin/manual/providers' class='button button-link has-icon icon-help' target='_blank'>Help</a><a href='https://localise.biz/wordpress/translation?l=de-DE' class='button button-link has-icon icon-group' target='_blank'>Need a human?</a></nav></div>")),clearInterval(checkModal)}}),100)}))}(window,jQuery);
automatic-translator-addon-for-loco-translate.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
  Description:Auto language translator add-on for Loco Translate official plugin version 2.4.0 to translate plugins and themes translation files into any language via fully automatic machine translations via Yandex Translate Widget.
5
- Version:2.1.2
6
  License:GPL2
7
  Text Domain:automatic-translator-addon-for-loco-translate
8
  Domain Path:languages
@@ -14,7 +14,7 @@ use LocoAutoTranslateAddon\Helpers\Helpers;
14
  use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
15
  /**
16
  * @package Loco Automatic Translate Addon
17
- * @version 2.1.2
18
  */
19
  if (!defined('ABSPATH')) {
20
  die('WordPress Environment Not Found!');
@@ -23,7 +23,7 @@ if (!defined('ABSPATH')) {
23
  define('ATLT_FILE', __FILE__);
24
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
25
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
26
- define('ATLT_VERSION', '2.1.2');
27
 
28
  class LocoAutoTranslate
29
  {
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
  Description:Auto language translator add-on for Loco Translate official plugin version 2.4.0 to translate plugins and themes translation files into any language via fully automatic machine translations via Yandex Translate Widget.
5
+ Version:2.1.3
6
  License:GPL2
7
  Text Domain:automatic-translator-addon-for-loco-translate
8
  Domain Path:languages
14
  use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
15
  /**
16
  * @package Loco Automatic Translate Addon
17
+ * @version 2.1.3
18
  */
19
  if (!defined('ABSPATH')) {
20
  die('WordPress Environment Not Found!');
23
  define('ATLT_FILE', __FILE__);
24
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
25
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
26
+ define('ATLT_VERSION', '2.1.3');
27
 
28
  class LocoAutoTranslate
29
  {
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
- === Automatic Translate Addon For Loco Translate ===
2
  Contributors: narinder-singh, satindersingh
3
  Donate link: https://paypal.me/CoolPlugins/10USD/
4
  Tags: translate, translation, translator, localization, language, translations, loco, loco translate, loco addon, google translate, deepl
5
  Requires at least: 4.5
6
- Tested up to: 5.5.3
7
  Requires PHP: 5.6
8
  Stable tag: trunk
9
  License: GPLv2 or later
@@ -13,11 +13,11 @@ Automatic language translator add-on for Loco Translate official plugin to trans
13
 
14
  == Description ==
15
 
16
- > **Important Notice:-** This plugin works as an auto-translate addon for Loco Translate official plugin latest version(2.4.6 or higher).
17
 
18
  ### 🐦 Automatic Machine Translator Addon For Loco
19
 
20
- Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin (**1,000,000+ Active Installations**) and automatically machine translate any WordPress plugin or theme translation files into any language.
21
 
22
  ### 🤖 No Translate API Required! + Unlimited Translations!
23
 
@@ -29,7 +29,7 @@ Install this plugin along with the famous **[Loco Translate](https://wordpress.o
29
 
30
  * One-click translate any plugin or theme all translatable strings. It will only translate plain text strings means if a string will contain HTML or special character then it will skipped from automatic translations.
31
  * You can automatic translate **unlimited characters** free of cost without any API key. You just need to install this addon and click on translate button to translate any plugin or theme strings.
32
- * After auto translations, you can manually edit any machine translated string inside Loco build-in editor.
33
 
34
  > “If you spend too much time thinking about a thing, you'll never get it done. Stop wasting time, complete work smartly & quickly!”
35
 
@@ -64,7 +64,7 @@ Install this plugin along with the famous **[Loco Translate](https://wordpress.o
64
 
65
  **🎬 Unlimited Translations(no API) - Pro Version Video**
66
 
67
- https://youtu.be/RkVwHB3hppo
68
 
69
  > “Many people make the mistake of saving money by wasting time.”
70
 
@@ -134,6 +134,11 @@ There is no limit. Yes, you can translate unlimited characters without any API k
134
  5. Premium License Pricing
135
 
136
  == Changelog ==
 
 
 
 
 
137
  <strong>Version 2.1.2 | 21 NOV 2020</strong>
138
  <pre>
139
  Fixed: Compatibility issues with Loco Translate 2.4.6
1
+ === Automatic Translate Addon For Loco Translate ===
2
  Contributors: narinder-singh, satindersingh
3
  Donate link: https://paypal.me/CoolPlugins/10USD/
4
  Tags: translate, translation, translator, localization, language, translations, loco, loco translate, loco addon, google translate, deepl
5
  Requires at least: 4.5
6
+ Tested up to: 5.7
7
  Requires PHP: 5.6
8
  Stable tag: trunk
9
  License: GPLv2 or later
13
 
14
  == Description ==
15
 
16
+ > **Important Notice:-** This plugin works as an auto-translate addon for Loco Translate official plugin latest version(2.4.4 or higher).
17
 
18
  ### 🐦 Automatic Machine Translator Addon For Loco
19
 
20
+ Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin (**1,000,000+ Active Installations**) and automatically machine translates any WordPress plugin or theme translation files into any language.
21
 
22
  ### 🤖 No Translate API Required! + Unlimited Translations!
23
 
29
 
30
  * One-click translate any plugin or theme all translatable strings. It will only translate plain text strings means if a string will contain HTML or special character then it will skipped from automatic translations.
31
  * You can automatic translate **unlimited characters** free of cost without any API key. You just need to install this addon and click on translate button to translate any plugin or theme strings.
32
+ * After auto translations, you can manually edit any machine translated string inside Loco built-in editor.
33
 
34
  > “If you spend too much time thinking about a thing, you'll never get it done. Stop wasting time, complete work smartly & quickly!”
35
 
64
 
65
  **🎬 Unlimited Translations(no API) - Pro Version Video**
66
 
67
+ https://www.youtube.com/watch?v=UdT6lRg_IHA&t=185s
68
 
69
  > “Many people make the mistake of saving money by wasting time.”
70
 
134
  5. Premium License Pricing
135
 
136
  == Changelog ==
137
+ <strong>Version 2.1.3 | 11 DEC 2020 </strong>
138
+ <pre>
139
+ Fixed: Compatibility issues with WordPress 5.6
140
+ Fixed: unable to save string issue with WordPress 5.6 version
141
+ </pre>
142
  <strong>Version 2.1.2 | 21 NOV 2020</strong>
143
  <pre>
144
  Fixed: Compatibility issues with Loco Translate 2.4.6