Version Description
Download this release
Release Info
Developer | Narinder singh |
Plugin | Automatic Translate Addon For Loco Translate |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8 to 1.9
- assets/css/atlt-admin-feedback-notice.css +0 -50
- assets/images/google-translate-button.png +0 -0
- assets/images/google-translate.png +0 -0
- assets/images/ibm-translate.png +0 -0
- assets/images/microsoft-translate.png +0 -0
- assets/images/powered-by-google.png +0 -0
- assets/images/yandex-translate.png +0 -0
- assets/js/loco-js-editor.js +21 -56
- assets/js/loco-js-editor.min.js +1 -1
- automatic-translator-addon-for-loco-translate.php +52 -22
- includes/Core/class.settings-api.php +6 -5
- includes/Core/class.settings-panel.php +17 -8
- includes/Helpers/Helpers.php +1 -1
- includes/Register/LocoAutomaticTranslateAddonPro.php +120 -45
- includes/Register/style.css +22 -4
- includes/ReviewNotice/class.review-notice.php +66 -6
- readme.txt +16 -5
assets/css/atlt-admin-feedback-notice.css
CHANGED
@@ -1,53 +1,3 @@
|
|
1 |
-
.atlt-feedback-notice-wrapper.notice.notice-info.is-dismissible {
|
2 |
-
padding: 5px;
|
3 |
-
margin: 10px 20px 10px 0;
|
4 |
-
border-left-color: #4aba4a;
|
5 |
-
}
|
6 |
-
|
7 |
-
.atlt-feedback-notice-wrapper .logo_container {
|
8 |
-
width: 80px;
|
9 |
-
display: inline-block;
|
10 |
-
margin-right: 10px;
|
11 |
-
vertical-align: top;
|
12 |
-
}
|
13 |
-
|
14 |
-
.atlt-feedback-notice-wrapper .logo_container img {
|
15 |
-
width: 100%;
|
16 |
-
height: auto;
|
17 |
-
}
|
18 |
-
|
19 |
-
.atlt-feedback-notice-wrapper .message_container {
|
20 |
-
width: calc(100% - 120px);
|
21 |
-
display: inline-block;
|
22 |
-
margin: 0;
|
23 |
-
vertical-align: top;
|
24 |
-
}
|
25 |
-
|
26 |
-
.atlt-feedback-notice-wrapper ul li {
|
27 |
-
float: left;
|
28 |
-
margin: 0px 5px;
|
29 |
-
}
|
30 |
-
|
31 |
-
.atlt-feedback-notice-wrapper ul li.already_rated a:before {
|
32 |
-
color: #cc0000;
|
33 |
-
content: "\f153";
|
34 |
-
font: normal 16px/20px dashicons;
|
35 |
-
display: inline-block;
|
36 |
-
vertical-align: middle;
|
37 |
-
margin-right: 4px;
|
38 |
-
height: 22px;
|
39 |
-
}
|
40 |
-
|
41 |
-
.atlt-feedback-notice-wrapper ul li.already_rated a[title="Not Interested"] {
|
42 |
-
position: absolute;
|
43 |
-
right: 5px;
|
44 |
-
top: 5px;
|
45 |
-
z-index: 9;
|
46 |
-
}
|
47 |
-
|
48 |
-
.clrfix {
|
49 |
-
clear: both;
|
50 |
-
}
|
51 |
|
52 |
.atlt-progress-bar-value {
|
53 |
width: 0px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
.atlt-progress-bar-value {
|
3 |
width: 0px;
|
assets/images/google-translate-button.png
ADDED
Binary file
|
assets/images/google-translate.png
ADDED
Binary file
|
assets/images/ibm-translate.png
ADDED
Binary file
|
assets/images/microsoft-translate.png
ADDED
Binary file
|
assets/images/powered-by-google.png
ADDED
Binary file
|
assets/images/yandex-translate.png
ADDED
Binary file
|
assets/js/loco-js-editor.js
CHANGED
@@ -11,13 +11,11 @@
|
|
11 |
let event = document.createEvent('event');
|
12 |
event.initEvent('atlt_run_translation');
|
13 |
createSettingsPopup();
|
14 |
-
|
15 |
-
$('#atlt-dialog .atlt-ok.button').on('click',function(){
|
16 |
// hide dialog container by finding main parent DOM
|
17 |
localStorage.removeItem('unSavedString');
|
18 |
$("#atlt-dialog").parent('.ui-dialog').hide();
|
19 |
});
|
20 |
-
|
21 |
var loco = window.locoScope,
|
22 |
conf = window.locoConf,
|
23 |
syncParams = null,
|
@@ -682,12 +680,12 @@ $(document).ready(function(){
|
|
682 |
if(type=="html"){
|
683 |
if((isHTML(item.source))){
|
684 |
item.target="";
|
685 |
-
}else if(isAllowedChars(item.source) && isPlacehodersChars(item.source)
|
686 |
item.target="";
|
687 |
}
|
688 |
}
|
689 |
if(type=="plain"){
|
690 |
-
if( isPlacehodersChars(item.source)
|
691 |
item.target="";
|
692 |
}
|
693 |
else if(isHTML(item.source) || isAllowedChars(item.source)){
|
@@ -738,7 +736,7 @@ $(document).ready(function(){
|
|
738 |
$("#atlt-settings-form").submit(function( event ) {
|
739 |
event.preventDefault();
|
740 |
const user_type=ATLT["info"].type;
|
741 |
-
let strType =
|
742 |
let apiType = $("input[name='api_type']:checked").val();
|
743 |
let mainBtn=$("#cool-auto-translate-btn");
|
744 |
var thisBtn=$("#cool-auto-translate-start");
|
@@ -746,10 +744,7 @@ $(document).ready(function(){
|
|
746 |
var todayLimit= mainBtn.data('today-limit');
|
747 |
var totalLimit= mainBtn.data('total-limit');
|
748 |
let targetLang='';
|
749 |
-
|
750 |
-
alert("HTML Translation Only Available in the PRO version");
|
751 |
-
return false;
|
752 |
-
}
|
753 |
if(user_type=="free" && apiType=="google"){
|
754 |
alert("Google Translation Only Available in the PRO version");
|
755 |
return false;
|
@@ -768,14 +763,6 @@ $(document).ready(function(){
|
|
768 |
}else{
|
769 |
targetLang=getTargetLang();
|
770 |
}
|
771 |
-
if(apiType=="google" && strType=="html"){
|
772 |
-
alert("Google Translate Only Support Plain Text Translation");
|
773 |
-
return false;
|
774 |
-
}
|
775 |
-
if(apiType=="microsoft" && strType=="html"){
|
776 |
-
alert("Microsoft Translator Only Support Plain Text Translation");
|
777 |
-
return false;
|
778 |
-
}
|
779 |
if(apiType=="google"){
|
780 |
if(targetLang=="zh"){
|
781 |
targetLang= targetLang+"-"+conf['locale']["region"];
|
@@ -837,18 +824,6 @@ $(document).ready(function(){
|
|
837 |
textToTranslateArr:plainStrArr,
|
838 |
strType:"plain",
|
839 |
};
|
840 |
-
}else{
|
841 |
-
if(htmlStrArr.length==0){
|
842 |
-
$("#atlt-dialog").parent('.ui-dialog').hide();
|
843 |
-
mainBtn.attr('disabled','disabled');
|
844 |
-
alert("You have no untranslated HTML strings");
|
845 |
-
window.location.reload();
|
846 |
-
return;
|
847 |
-
}
|
848 |
-
dataObj = {
|
849 |
-
textToTranslateArr:htmlStrArr,
|
850 |
-
strType:"html",
|
851 |
-
};
|
852 |
}
|
853 |
// create data object for later use
|
854 |
dataObj.orgStrArr=orgStrArr;
|
@@ -933,15 +908,12 @@ function atlt_translate(data) {
|
|
933 |
|
934 |
atlt_ajax_translation_request(data, "POST").success(function(
|
935 |
resp,status,xhr) {
|
936 |
-
// console.log(resp);
|
937 |
-
|
938 |
if(xhr.status==200 && resp!=null){
|
939 |
|
940 |
const json_resp = JSON.parse(resp);
|
941 |
let responseObj;
|
942 |
let apiProvider=window.locoEditorStats.dataObj.apiType;
|
943 |
-
|
944 |
-
|
945 |
if(json_resp['error'] && json_resp['error']['code']==800)
|
946 |
{
|
947 |
let errorMsz= json_resp['error']['message'];
|
@@ -1154,7 +1126,7 @@ function filterRawObject(rawArray,filterType){
|
|
1154 |
(Array.isArray(htmlStrings)&& htmlStrings.length)
|
1155 |
){
|
1156 |
const inActiveBtn='<fieldset><button title="Add API key to enable this feature." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button> <a style="font-size:9px;display:block;margin-left:8px;" target="_blank" href="https://www.ibm.com/in-en/cloud/watson-language-translator/pricing">Get Free API Key</a></fieldset>';
|
1157 |
-
const disabledBtn='<fieldset><button title="Buy PRO." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button><div style="max-width:320px; display:inline-block;margin-top: 4px;"><span style="font-size:12px;display:inline-block;margin-left:8px;">You have exceeded free translation limit. In order to extend the limit - <a target="_blank" style="font-size:14px;display:inline-block;margin-left:8px;" target="_blank" href="https://
|
1158 |
const apiKey=ATLT["api_key"]["yApiKey"];
|
1159 |
const proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';
|
1160 |
const allowed=ATLT["info"].allowed;
|
@@ -1228,8 +1200,6 @@ if((Array.isArray(savedStrings) && savedStrings.length)){
|
|
1228 |
}
|
1229 |
|
1230 |
}
|
1231 |
-
|
1232 |
-
|
1233 |
// mark unsaved after ajax translation process
|
1234 |
function markUnsavedString(){
|
1235 |
const unSavedString = JSON.parse(localStorage.getItem('unSavedString'));
|
@@ -1305,6 +1275,7 @@ function atltFormatNumber(num) {
|
|
1305 |
// create popup model for translation settings
|
1306 |
function createSettingsPopup(){
|
1307 |
let preloaderImg=extradata['preloader_path'];
|
|
|
1308 |
const userInfo=ATLT["info"].type;
|
1309 |
const yAC=ATLT["info"].yAvailableChars;
|
1310 |
const iAC=ATLT["info"].iAvailableChars;
|
@@ -1336,7 +1307,7 @@ function createSettingsPopup(){
|
|
1336 |
contCls="html-disabled";
|
1337 |
gContCls='g-disabled';
|
1338 |
mContCls='m-disabled';
|
1339 |
-
proLbl='<span class="atlt-pro-feature"><a href="https://
|
1340 |
|
1341 |
gHtml=proLbl+' ';
|
1342 |
mHtml=proLbl+' ';
|
@@ -1409,7 +1380,7 @@ if(ATLT["api_key"]["ibmApiKey"]=="" || ATLT["info"]["ibm_url"]==""){
|
|
1409 |
plainStringLbl='Translate Plain Text Strings';
|
1410 |
}
|
1411 |
|
1412 |
-
if( ATLT["api_key"]["yApiKey"]!="" || ATLT["api_key"]["gApiKey"]!="" || ATLT["api_key"]["mApiKey"]!="" )
|
1413 |
{
|
1414 |
submitBtn='<input type="submit" class="button has-icon icon-translate" value="Start Translation" id="cool-auto-translate-start">';
|
1415 |
}else{
|
@@ -1417,14 +1388,22 @@ if(ATLT["api_key"]["ibmApiKey"]=="" || ATLT["info"]["ibm_url"]==""){
|
|
1417 |
|
1418 |
}
|
1419 |
let settingsHTML=`<div class="atlt-settings">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1420 |
<form id="atlt-settings-form" method="post" action="#">
|
1421 |
-
<strong class="atlt-heading">
|
1422 |
<div class="inputGroup">
|
1423 |
<input class="inputEle" type="radio" id="ibm_api"
|
1424 |
${iChecked} ${ifieldStatus} name="api_type" value="ibm">
|
1425 |
<label for="ibm_api">IBM Translate ${iHtml}</label>
|
1426 |
</div>
|
1427 |
-
|
1428 |
<div class="inputGroup">
|
1429 |
<input class="inputEle" type="radio" id="yandex_api"
|
1430 |
${yChecked} ${yfieldStatus} name="api_type" value="yandex">
|
@@ -1441,22 +1420,8 @@ if(ATLT["api_key"]["ibmApiKey"]=="" || ATLT["info"]["ibm_url"]==""){
|
|
1441 |
name="api_type" value="microsoft" ${mfieldStatus}>
|
1442 |
<label for="microsoft_api">Microsoft Translator ${mHtml}</label>
|
1443 |
<br/>
|
1444 |
-
<small style="display:inline-block;margin-left:24px;margin-top:8px;font-weight:bold;">(<a href="https://
|
1445 |
-
</div>
|
1446 |
-
<br/>
|
1447 |
-
<strong class="atlt-heading">Select Content Type</strong>
|
1448 |
-
<div class="inputGroup">
|
1449 |
-
<input class="inputEle" type="radio" id="typeplain" checked="true" name="translationtype" value="plain">
|
1450 |
-
<label for="typeplain">${plainStringLbl}</label>
|
1451 |
-
</div>
|
1452 |
-
<div id="typehtmlWrapper" class="inputGroup ${contCls}">
|
1453 |
-
<input class="inputEle" type="radio" id="typehtml" name="translationtype" value="html" ${hfieldStatus}>
|
1454 |
-
<label for="typehtml">Translate HTML Strings (Supported by Yandex API v1) ${proLbl}
|
1455 |
-
</label>
|
1456 |
-
</br>
|
1457 |
-
<small style="display:inline-block;margin-left:24px;margin-top:8px;font-weight:bold;">(<a href="https://locotranslate.com/html-translation-languages-list/" target="_blank">List of languages with HTML support</a>)</small>
|
1458 |
</div>
|
1459 |
-
|
1460 |
<br/>
|
1461 |
<fieldset>
|
1462 |
${submitBtn}
|
11 |
let event = document.createEvent('event');
|
12 |
event.initEvent('atlt_run_translation');
|
13 |
createSettingsPopup();
|
14 |
+
$('#atlt-dialog .atlt-ok.button').on('click',function(){
|
|
|
15 |
// hide dialog container by finding main parent DOM
|
16 |
localStorage.removeItem('unSavedString');
|
17 |
$("#atlt-dialog").parent('.ui-dialog').hide();
|
18 |
});
|
|
|
19 |
var loco = window.locoScope,
|
20 |
conf = window.locoConf,
|
21 |
syncParams = null,
|
680 |
if(type=="html"){
|
681 |
if((isHTML(item.source))){
|
682 |
item.target="";
|
683 |
+
}else if(isAllowedChars(item.source) && isPlacehodersChars(item.source)===false){
|
684 |
item.target="";
|
685 |
}
|
686 |
}
|
687 |
if(type=="plain"){
|
688 |
+
if( isPlacehodersChars(item.source)===true){
|
689 |
item.target="";
|
690 |
}
|
691 |
else if(isHTML(item.source) || isAllowedChars(item.source)){
|
736 |
$("#atlt-settings-form").submit(function( event ) {
|
737 |
event.preventDefault();
|
738 |
const user_type=ATLT["info"].type;
|
739 |
+
let strType ="plain";
|
740 |
let apiType = $("input[name='api_type']:checked").val();
|
741 |
let mainBtn=$("#cool-auto-translate-btn");
|
742 |
var thisBtn=$("#cool-auto-translate-start");
|
744 |
var todayLimit= mainBtn.data('today-limit');
|
745 |
var totalLimit= mainBtn.data('total-limit');
|
746 |
let targetLang='';
|
747 |
+
|
|
|
|
|
|
|
748 |
if(user_type=="free" && apiType=="google"){
|
749 |
alert("Google Translation Only Available in the PRO version");
|
750 |
return false;
|
763 |
}else{
|
764 |
targetLang=getTargetLang();
|
765 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
766 |
if(apiType=="google"){
|
767 |
if(targetLang=="zh"){
|
768 |
targetLang= targetLang+"-"+conf['locale']["region"];
|
824 |
textToTranslateArr:plainStrArr,
|
825 |
strType:"plain",
|
826 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
}
|
828 |
// create data object for later use
|
829 |
dataObj.orgStrArr=orgStrArr;
|
908 |
|
909 |
atlt_ajax_translation_request(data, "POST").success(function(
|
910 |
resp,status,xhr) {
|
|
|
|
|
911 |
if(xhr.status==200 && resp!=null){
|
912 |
|
913 |
const json_resp = JSON.parse(resp);
|
914 |
let responseObj;
|
915 |
let apiProvider=window.locoEditorStats.dataObj.apiType;
|
916 |
+
|
|
|
917 |
if(json_resp['error'] && json_resp['error']['code']==800)
|
918 |
{
|
919 |
let errorMsz= json_resp['error']['message'];
|
1126 |
(Array.isArray(htmlStrings)&& htmlStrings.length)
|
1127 |
){
|
1128 |
const inActiveBtn='<fieldset><button title="Add API key to enable this feature." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button> <a style="font-size:9px;display:block;margin-left:8px;" target="_blank" href="https://www.ibm.com/in-en/cloud/watson-language-translator/pricing">Get Free API Key</a></fieldset>';
|
1129 |
+
const disabledBtn='<fieldset><button title="Buy PRO." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button><div style="max-width:320px; display:inline-block;margin-top: 4px;"><span style="font-size:12px;display:inline-block;margin-left:8px;">You have exceeded free translation limit. In order to extend the limit - <a target="_blank" style="font-size:14px;display:inline-block;margin-left:8px;" target="_blank" href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing">Buy Premium License</a></span></div></fieldset>';
|
1130 |
const apiKey=ATLT["api_key"]["yApiKey"];
|
1131 |
const proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';
|
1132 |
const allowed=ATLT["info"].allowed;
|
1200 |
}
|
1201 |
|
1202 |
}
|
|
|
|
|
1203 |
// mark unsaved after ajax translation process
|
1204 |
function markUnsavedString(){
|
1205 |
const unSavedString = JSON.parse(localStorage.getItem('unSavedString'));
|
1275 |
// create popup model for translation settings
|
1276 |
function createSettingsPopup(){
|
1277 |
let preloaderImg=extradata['preloader_path'];
|
1278 |
+
let gtPreviewImg=extradata['gt_preview'];
|
1279 |
const userInfo=ATLT["info"].type;
|
1280 |
const yAC=ATLT["info"].yAvailableChars;
|
1281 |
const iAC=ATLT["info"].iAvailableChars;
|
1307 |
contCls="html-disabled";
|
1308 |
gContCls='g-disabled';
|
1309 |
mContCls='m-disabled';
|
1310 |
+
proLbl='<span class="atlt-pro-feature"><a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing" target="_blank" style="color:red;font-weight:bold;font-size:0.9em;" title="Only For Pro Users">PRO Only</a></span>';
|
1311 |
|
1312 |
gHtml=proLbl+' ';
|
1313 |
mHtml=proLbl+' ';
|
1380 |
plainStringLbl='Translate Plain Text Strings';
|
1381 |
}
|
1382 |
|
1383 |
+
if( ATLT["api_key"]["yApiKey"]!="" || ATLT["api_key"]["gApiKey"]!="" || ATLT["api_key"]["mApiKey"]!="" || ATLT["api_key"]["ibmApiKey"]!="")
|
1384 |
{
|
1385 |
submitBtn='<input type="submit" class="button has-icon icon-translate" value="Start Translation" id="cool-auto-translate-start">';
|
1386 |
}else{
|
1388 |
|
1389 |
}
|
1390 |
let settingsHTML=`<div class="atlt-settings">
|
1391 |
+
<strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Button<br/>(No API Key Required + Unlimited Translations!)</strong>
|
1392 |
+
<div class="inputGroup">
|
1393 |
+
<button id="atlt_gtranslate_btn" disabled="true" class="notranslate button button-primary">Google Translate</button>
|
1394 |
+
<br/><img src="${gtPreviewImg}" alt="google translate widget preview"><br/>
|
1395 |
+
${proLbl}
|
1396 |
+
✅ Available Inside Pro Version 1.1<br/><span style="font-size:11px;font-weight:bold;">(Release date:- 27 June, 2020)</span>
|
1397 |
+
</div>
|
1398 |
+
<hr/>
|
1399 |
+
<div class="atlt-settings">
|
1400 |
<form id="atlt-settings-form" method="post" action="#">
|
1401 |
+
<strong class="atlt-heading" style="margin:15px 0 10px;display:inline-block;">Translate Using A Translate API</strong>
|
1402 |
<div class="inputGroup">
|
1403 |
<input class="inputEle" type="radio" id="ibm_api"
|
1404 |
${iChecked} ${ifieldStatus} name="api_type" value="ibm">
|
1405 |
<label for="ibm_api">IBM Translate ${iHtml}</label>
|
1406 |
</div>
|
|
|
1407 |
<div class="inputGroup">
|
1408 |
<input class="inputEle" type="radio" id="yandex_api"
|
1409 |
${yChecked} ${yfieldStatus} name="api_type" value="yandex">
|
1420 |
name="api_type" value="microsoft" ${mfieldStatus}>
|
1421 |
<label for="microsoft_api">Microsoft Translator ${mHtml}</label>
|
1422 |
<br/>
|
1423 |
+
<small style="display:inline-block;margin-left:24px;margin-top:8px;font-weight:bold;">(<a href="https://locoaddon.com/supported-languages/" target="_blank">View all supported languages list</a>)</small>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1424 |
</div>
|
|
|
1425 |
<br/>
|
1426 |
<fieldset>
|
1427 |
${submitBtn}
|
assets/js/loco-js-editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(window,$){var TotalCharacters=0,HtmlStrings=0,requestChars=0;let event;document.createEvent("event").initEvent("atlt_run_translation"),createSettingsPopup(),$("#atlt-dialog .atlt-ok.button").on("click",(function(){localStorage.removeItem("unSavedString"),$("#atlt-dialog").parent(".ui-dialog").hide()}));var loco=window.locoScope,conf=window.locoConf,syncParams=null,saveParams=null,translator=loco.l10n,sprintf=loco.string.sprintf,locale=conf.locale,messages=loco.po.init(locale).wrap(conf.powrap),template=!locale,elForm=document.getElementById("loco-actions"),filePath=conf.popath,syncPath=conf.potpath,elFilesys=document.getElementById("loco-fs"),fsConnect=elFilesys&&loco.fs.init(elFilesys),readonly,editable=!conf.readonly,editor,saveButton,innerDiv=document.getElementById("loco-editor-inner");function doSyncAction(callback){function onSuccess(result){var info=[],doc=messages,exp=result.po,src=result.pot,pot=loco.po.init().load(exp),done=doc.merge(pot),nadd=done.add.length,ndel=done.del.length,t=translator;editor.load(doc),nadd||ndel?(src?info.push(sprintf(t._("Merged from %s"),src)):info.push(t._("Merged from source code")),nadd&&info.push(sprintf(t._n("1 new string added","%s new strings added",nadd),nadd)),ndel&&info.push(sprintf(t._n("1 obsolete string removed","%s obsolete strings removed",ndel),ndel)),$(innerDiv).trigger("poUnsaved",[]),updateStatus(),window.console&&debugMerge(console,done)):src?info.push(sprintf(t._("Already up to date with %s"),src)):info.push(t._("Already up to date with source code")),loco.notices.success(info.join(". ")),$(innerDiv).trigger("poMerge",[result]),callback&&callback()}loco.ajax.post("sync",syncParams,onSuccess,callback)}function debugMerge(console,result){for(var i=-1,t=result.add.length;++i<t;)console.log(" + "+result.add[i].source());for(i=-1,t=result.del.length;++i<t;)console.log(" - "+result.del[i].source())}function doSaveAction(callback){function onSuccess(result){callback&&callback(),editor.save(!0),$("#loco-po-modified").text(result.datetime||"[datetime error]")}saveParams.locale=String(messages.locale()||""),fsConnect&&fsConnect.applyCreds(saveParams),saveParams.data=String(messages),loco.ajax.post("save",saveParams,onSuccess,callback)}function saveIfDirty(){editor.dirty&&doSaveAction()}function onUnloadWarning(){return translator._("Your changes will be lost if you continue without saving")}function registerSaveButton(button){function disable(){button.disabled=!0}function enable(){button.disabled=!1}function think(){disable(),$(button).addClass("loco-loading")}function unthink(){enable(),$(button).removeClass("loco-loading")}return saveButton=button,editor.on("poUnsaved",(function(){enable(),$(button).addClass("button-primary loco-flagged")})).on("poSave",(function(){disable(),$(button).removeClass("button-primary loco-flagged")})),saveParams=$.extend({path:filePath},conf.project||{}),$(button).click((function(event){return event.preventDefault(),think(),doSaveAction(unthink),setTimeout((function(){location.reload()}),3500),!1})),!0}function registerSyncButton(button){var project=conf.project;if(project){function disable(){button.disabled=!0}function enable(){button.disabled=!1}function think(){disable(),$(button).addClass("loco-loading")}function unthink(){enable(),$(button).removeClass("loco-loading")}editor.on("poUnsaved",(function(){disable()})).on("poSave",(function(){enable()})),syncParams={bundle:project.bundle,domain:project.domain,type:template?"pot":"po",sync:syncPath||""},$(button).click((function(event){return event.preventDefault(),think(),doSyncAction(unthink),!1})),enable()}return!0}function registerFuzzyButton(button){var toggled=!1,enabled=!1;function redraw(message,state){var allowed=message&&message.translated(0)||!1;enabled!==allowed&&(button.disabled=!allowed,enabled=allowed),state!==toggled&&($(button)[state?"addClass":"removeClass"]("inverted"),toggled=state)}return editor.on("poSelected",(function(event,message){redraw(message,message&&message.fuzzy()||!1)})).on("poEmpty",(function(event,blank,message,pluralIndex){0===pluralIndex&&blank===enabled&&redraw(message,toggled)})).on("poFuzzy",(function(event,message,newState){redraw(message,newState)})),$(button).click((function(event){return event.preventDefault(),editor.fuzzy(!editor.fuzzy()),!1})),!0}function registerRevertButton(button){return editor.on("poUnsaved",(function(){button.disabled=!1})).on("poSave",(function(){button.disabled=!0})),$(button).click((function(event){return event.preventDefault(),location.reload(),!1})),!0}function registerInvisiblesButton(button){var $button=$(button);return button.disabled=!1,editor.on("poInvs",(function(event,state){$button[state?"addClass":"removeClass"]("inverted")})),$button.click((function(event){return event.preventDefault(),editor.setInvs(!editor.getInvs()),!1})),locoScope.tooltip.init($button),!0}function registerCodeviewButton(button){var $button=$(button);return button.disabled=!1,$button.click((function(event){event.preventDefault();var state=!editor.getMono();return editor.setMono(state),$button[state?"addClass":"removeClass"]("inverted"),!1})),locoScope.tooltip.init($button),!0}function registerAddButton(button){return button.disabled=!1,$(button).click((function(event){event.preventDefault();var i=1,baseid,msgid,regex=/(\d+)$/;for(msgid=baseid="New message";messages.get(msgid);)i=regex.exec(msgid)?Math.max(i,RegExp.$1):i,msgid=baseid+" "+ ++i;return editor.add(msgid),!1})),!0}function registerDelButton(button){return button.disabled=!1,$(button).click((function(event){return event.preventDefault(),editor.del(),!1})),!0}function registerDownloadButton(button,id){return button.disabled=!1,$(button).click((function(event){var form=button.form,path=filePath;return"binary"===id&&(path=path.replace(/\.po$/,".mo")),form.path.value=path,form.source.value=messages.toString(),!0})),!0}function noop(event){return event.preventDefault(),!1}function updateStatus(){var t=translator,stats=editor.stats(),total=stats.t,fuzzy=stats.f,empty=stats.u,stext=sprintf(t._n("1 string","%s strings",total),total.format(0)),extra=[];locale&&(stext=sprintf(t._("%s%% translated"),stats.p.replace("%",""))+", "+stext,fuzzy&&extra.push(sprintf(t._("%s fuzzy"),fuzzy.format(0))),empty&&extra.push(sprintf(t._("%s untranslated"),empty.format(0))),extra.length&&(stext+=" ("+extra.join(", ")+")")),$("#loco-po-status").text(stext),void 0===window.locoEditorStats?window.locoEditorStats={totalWords:stats.t,totalTranslated:stats.p}:(window.locoEditorStats.totalWords=stats.t,window.locoEditorStats.totalTranslated=stats.p)}function initSearchFilter(elSearch){function showValidFilter(numFound){$(elSearch.parentNode)[numFound||null==numFound?"removeClass":"addClass"]("invalid")}editor.searchable(loco.fulltext.init()),elSearch.disabled=!1,elSearch.value="";var listener=loco.watchtext(elSearch,(function(value){var numFound;showValidFilter(editor.filter(value,!0))}));editor.on("poFilter",(function(event,value,numFound){listener.val(value||""),showValidFilter(numFound)})).on("poMerge",(function(event,result){var value=listener.val();value&&editor.filter(value)}))}var resize=function(){function top(el,ancestor){for(var y=el.offsetTop||0;(el=el.offsetParent)&&el!==ancestor;)y+=el.offsetTop||0;return y}var fixHeight,minHeight=parseInt($(innerDiv).css("min-height")||0);return function(){var padBottom=20,topBanner=top(innerDiv,document.body),winHeight=window.innerHeight,setHeight=Math.max(minHeight,winHeight-topBanner-20);fixHeight!==setHeight&&(innerDiv.style.height=String(setHeight)+"px",fixHeight=setHeight)}}();resize(),$(window).resize(resize),innerDiv.innerHTML="",editor=loco.po.ed.init(innerDiv).localise(translator),loco.po.kbd.init(editor).add("save",saveIfDirty).enable("copy","clear","enter","next","prev","fuzzy","save","invis");var buttons={save:editable&®isterSaveButton,sync:editable&®isterSyncButton,revert:registerRevertButton,invs:registerInvisiblesButton,code:registerCodeviewButton,source:registerDownloadButton,binary:template?null:registerDownloadButton};function createEncodedString(allStringText){const queryString=allStringText.map(item=>"&text="+encodeURIComponent(item.source)).join(",");return queryString}function validLicenseKey(licenseKey){if(!(null!=licenseKey&&licenseKey.length>1))return!1;{let validKey;if(validate_pattern(licenseKey).length>1)return licenseKey}}function savedTimeInfo(statsObj){var info="";if(null!=statsObj&&void 0!==statsObj.time_saved){let timeSaved,totalChars;var info=`<div class="saved_time_wrapper" style="margin:10px 0px">\n <span style="border: 3px solid #14b75d;display: inline-block;padding: 3px;">\n Wahooo! You have saved your \n <strong>${statsObj.time_saved}</strong> \n via auto translating <strong>${statsObj.totalChars}</strong> \n characters using <strong> <br />\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></strong>\n </span></div>`}return info}function validate_pattern(str){let m;const regex=/^([A-Z0-9]{8})-([A-Z0-9]{8})-([A-Z0-9]{8})-([A-Z0-9]{8})$/gm;let saveMatch=[];for(;null!==(m=regex.exec(str));)m.index===regex.lastIndex&®ex.lastIndex++,m.forEach((match,groupIndex)=>{saveMatch.push(match)});return saveMatch}function getTargetLang(){return window.locoConf.locale.lang?window.locoConf.locale.lang:null}function atlt_translate(data){atlt_ajax_translation_request(data,"POST").success((function(resp,status,xhr){if(200==xhr.status&&null!=resp){const json_resp=JSON.parse(resp);let responseObj,apiProvider=window.locoEditorStats.dataObj.apiType;if(json_resp.error&&800==json_resp.error.code){let errorMsz=json_resp.error.message;return $("#atlt-dialog .atlt-final-message").html("<p style='color:red;margin:5px 2px;font-weight:bold;'>"+errorMsz+"</p>"),$("#atlt-dialog .atlt-ok.button").show(),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Error").attr("disabled","disabled"),setTimeout((function(){location.reload()}),4e3),!1}if(null==json_resp.translatedString||!json_resp.translatedString.length||200!=json_resp.code){let errorCode=json_resp.code,errorMsz=json_resp.error;return $("#atlt-dialog .atlt-final-message").html("<p style='color:red;margin:5px 2px;font-weight:bold;'>"+errorMsz+"</p>"),$("#atlt-dialog .atlt-ok.button").show(),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Error").attr("disabled","disabled"),setTimeout((function(){location.reload()}),4e3),!1}responseObj=json_resp.translatedString;let totalTranslated=window.locoEditorStats.totalTranslated,unSavedStr=[];if(void 0!==responseObj&&responseObj.length)for(i=0;i<responseObj.length;i++){var text=responseObj[i];if(void 0===data.textToTranslateArr[i])break;data.textToTranslateArr[i].target=text}let translatedStrArr=data.textToTranslateArr,Emptytargets=[],items;for(var x=0;x<translatedStrArr.length;++x)""!=translatedStrArr[x].target&&(Emptytargets[x]=translatedStrArr[x].source);items=localStorage.getItem("unSavedString")?JSON.parse(localStorage.getItem("unSavedString")):[];var unSavedStrArr=items.concat(Emptytargets);localStorage.setItem("unSavedString",JSON.stringify(unSavedStrArr)),(messages=loco.po.init(locale).wrap(conf.powrap)).load(conf.podata),editor.on("poUnsaved",(function(){window.onbeforeunload=onUnloadWarning})).on("poSave",(function(){updateStatus(),window.onbeforeunload=null})).on("poUpdate",updateStatus),editor.load(messages),data.saveBtn.addClass("button-primary loco-flagged").removeAttr("disabled"),updateStatus(),markUnsavedString(),requestChars=0,$("#atlt-dialog .translated-label").text("Translated"),$("#atlt-dialog .translated-text").text(window.locoEditorStats.totalTranslated),$("#atlt-dialog .atlt-progress-bar-value").width(window.locoEditorStats.totalTranslated);let saved_time_html=savedTimeInfo(json_resp.stats),finalHTML="<strong style='font-size:18px;display:inline-block;margin:5px auto;'>Translation Complete!</strong><br/>(Close this popup & Click <strong>Save</strong>).";switch(window.locoEditorStats.totalTranslated){case"0%":$("#atlt-dialog .translated-label").text("Translating..."),$("#atlt-dialog .translated-text").text("");break;case"100%":return data.thisBtn.hide(),$("#atlt_preloader").hide(),data.thisBtn.attr("disabled","disabled"),$("#cool-auto-translate-btn").text("Translated - SAVE NOW").attr("disabled","disabled"),$("#atlt-dialog .atlt-final-message").html(finalHTML+saved_time_html),void $("#atlt-dialog .atlt-ok.button").show()}for(var x=0;x<=Emptytargets.length;x++){var source=Emptytargets[x];jQuery("#po-list-tbody div[for='po-list-col-source'] div").filter((function(index){return jQuery(this).text()==source})).addClass("po-unsaved")}if(0==window.locoEditorStats.dataObj.textToTranslateArr.length)return data.thisBtn.val("Translated").attr("disabled","true"),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Translated - SAVE NOW").attr("disabled","disabled"),$("#atlt-dialog .atlt-final-message").html(finalHTML+saved_time_html),void $("#atlt-dialog .atlt-ok.button").show();jQuery(document).trigger("atlt_run_translation")}else data.thisBtn.hide("slow"),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Translation").attr("disabled","disabled"),$("#atlt-dialog .atlt-ok.button").show(),alert("Unable to make request to the server at the moment. Try again later.")})).fail((function(jqXHR){console.log(jqXHR),500!=jqXHR.status&&0!=jqXHR.status||(data.thisBtn.hide("slow"),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Translation").attr("disabled","disabled"),$("#atlt-dialog .atlt-ok.button").show(),alert("Unable to make request to the server at the moment. Try again later."))}))}function filterSavedStrings(rawArray){return filterdArr=rawArray.filter((item,index)=>{if(""!=item.target&&void 0!==item.source&&""!=item.source)return!0})}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)&&("html"==filterType?!!isHTML(item.source)||!(!isAllowedChars(item.source)||0!=isPlacehodersChars(item.source)):!isHTML(item.source)&&(!!isPlacehodersChars(item.source)||!isSpecialChars(item.source)&&!item.source.includes("#")))})}function addAutoTranslationBtn(){$("#loco-toolbar").find("#cool-auto-translate-btn").length>0&&$("#loco-toolbar").find("#cool-auto-translate-btn").remove();const locoActions=$("#loco-toolbar").find("#loco-actions"),otherBtn='<button class="button has-icon icon-warn" id="atlt_reset_all">Reset Translations</button></fieldset>',allTranslated='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate" disabled>Translated</button></fieldset>';let savedStrings=filterSavedStrings(conf.podata),plainStrings=filterRawObject(conf.podata,"plain"),htmlStrings=filterRawObject(conf.podata,"html");const userType=ATLT.info.type;if(Array.isArray(plainStrings)&&plainStrings.length||Array.isArray(htmlStrings)&&htmlStrings.length){const inActiveBtn='<fieldset><button title="Add API key to enable this feature." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button> <a style="font-size:9px;display:block;margin-left:8px;" target="_blank" href="https://www.ibm.com/in-en/cloud/watson-language-translator/pricing">Get Free API Key</a></fieldset>',disabledBtn='<fieldset><button title="Buy PRO." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button><div style="max-width:320px; display:inline-block;margin-top: 4px;"><span style="font-size:12px;display:inline-block;margin-left:8px;">You have exceeded free translation limit. In order to extend the limit - <a target="_blank" style="font-size:14px;display:inline-block;margin-left:8px;" target="_blank" href="https://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing">Buy Premium License</a></span></div></fieldset>',apiKey=ATLT.api_key.yApiKey,proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>',allowed=ATLT.info.allowed,today=ATLT.info.today,total=ATLT.info.total,aTodayChars=3e5,aTodayChar=1e6;if(null==ATLT||""==ATLT.api_key){if("free"==userType)return void locoActions.append(inActiveBtn);locoActions.append(proActiveBtn)}else if(""==ATLT.api_key.yApiKey&&""==ATLT.api_key.ibmApiKey){if("free"==userType)return void locoActions.append(inActiveBtn);locoActions.append(proActiveBtn)}else{if("no"==allowed&&"free"==userType)return void locoActions.append(disabledBtn);if(void 0!==today&&parseInt(today)>aTodayChars&&"free"==userType)return void locoActions.append(disabledBtn);if(void 0!==total&&parseInt(total)>aTodayChar&&"free"==userType)return void locoActions.append(disabledBtn);if("100%"!=window.locoEditorStats.totalTranslated&&window.locoEditorStats.totalWords>0)if("pro"==userType&&null!=ATLT.info.licenseKey&&validLicenseKey(ATLT.info.licenseKey))locoActions.append(proActiveBtn);else{if(null==today)var todayChars=aTodayChars;else var todayChars=aTodayChars-parseInt(today);var totalChars,freeBtn='<fieldset><button data-today-limit="'+todayChars+'" data-total-limit="'+(aTodayChar-parseInt(total))+'" id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(freeBtn)}else if(0==window.locoEditorStats.totalWords)return}}else locoActions.append(allTranslated);Array.isArray(savedStrings)&&savedStrings.length&&"pro"==userType&&null!=ATLT.info.licenseKey&&validLicenseKey(ATLT.info.licenseKey)&&"yes"==ATLT.info.proInstalled&&locoActions.append(otherBtn)}function markUnsavedString(){const unSavedString=JSON.parse(localStorage.getItem("unSavedString"));for(var x=0;x<=unSavedString.length;x++){var source=unSavedString[x];jQuery("#po-list-tbody div[for='po-list-col-source'] div").filter((function(index){return jQuery(this).text()==source})).addClass("po-unsaved")}}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 isAllowedChars(str){var rgex;return void 0!==str&&/[!@#$%^&*(),?":|<>]/g.test(str)}function isPlacehodersChars(str){var rgex;return void 0!==str&&/%s|%d/g.test(str)}function isContainChars(str){var rgex;return void 0!==str&&/[{}[]/g.test(str)}function atltFormatNumber(num){return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")}function createSettingsPopup(){let preloaderImg=extradata.preloader_path;const userInfo=ATLT.info.type,yAC=ATLT.info.yAvailableChars,iAC=ATLT.info.iAvailableChars,licenseKey=ATLT.info.licenseKey,proInstalled=ATLT.info.proInstalled;let yfieldStatus="",ifieldStatus="",gfieldStatus="",mfieldStatus="",hfieldStatus="",htmlSupported="",contCls="",icontCls="",proLbl="",gContCls="",gHtml="",mContCls="",mHtml="",submitBtn="",yHtml="",iHtml="",yChecked='"',iChecked='checked="true"';if("free"==userInfo){let gAC=0;gfieldStatus="disabled",mfieldStatus="disabled",hfieldStatus="disabled",contCls="html-disabled",gContCls="g-disabled",mContCls="m-disabled",proLbl='<span class="atlt-pro-feature"><a href="https://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing" target="_blank" style="color:red;font-weight:bold;font-size:0.9em;" title="Only For Pro Users">PRO Only</a></span>',gHtml=proLbl+" ",mHtml=proLbl+" "}else if("no"==proInstalled)gfieldStatus="disabled",mfieldStatus="disabled",hfieldStatus="disabled",contCls="html-disabled",gContCls="g-disabled",mContCls="m-disabled",proLbl='<span style="color:red;font-weight:bold;font-size:0.9em;" class="atlt-pro-feature">Please Install PRO version</span>',gHtml=proLbl+" ",mHtml=proLbl+" ";else if(null!=ATLT.info.licenseKey&&validLicenseKey(ATLT.info.licenseKey)){if(""!=ATLT.api_key.gApiKey){let gAC=ATLT.info.gAvailableChars;void 0!==gAC&&gAC>1e4?gHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(gAC)+" Free Char. Available This Month)</span>":gAC<1e4&&(gHtml='<span class="used-chars" style="font-weight:bold;font-size:0.9em;">(You have consumed all free characters.)</span>')}else gfieldStatus="disabled",gContCls="g-disabled",gHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Google Translate API key)</span>';null!=ATLT.api_key.mApiKey&&""!=ATLT.api_key.mApiKey?(mAC=ATLT.info.mAvailableChars,void 0!==mAC&&mAC>1e4?mHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(mAC)+" Free Char. Available This Month)</span>":mAC<1e4&&(mHtml='<span class="used-chars" style="font-weight:bold;font-size:0.9em;">(You have consumed all free characters.)</span>')):(mfieldStatus="disabled",mContCls="m-disabled",mHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Microsoft Translator API key)</span>')}""!=ATLT.api_key.yApiKey?void 0!==yAC&&(yHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(yAC)+" Free Char. Available Monthly)</span>"):(yfieldStatus="disabled",yContCls="g-disabled",yChecked="",yHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Yandex Translate API v1 key)</span>'),""==ATLT.api_key.ibmApiKey||""==ATLT.info.ibm_url?(ifieldStatus="disabled",iContCls="g-disabled",iChecked="",iHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter IBM Translate API key/URL)</span>'):void 0!==iAC&&(iHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(iAC)+" Free Char. Available Monthly)</span>"),plainStringLbl="free"==userInfo?"Translate Plain Text Strings(No HTML/Special character supported)":"Translate Plain Text Strings",submitBtn=""!=ATLT.api_key.yApiKey||""!=ATLT.api_key.gApiKey||""!=ATLT.api_key.mApiKey?'<input type="submit" class="button has-icon icon-translate" value="Start Translation" id="cool-auto-translate-start">':'<button class="atlt-ok button button-primary">OK</button>';let settingsHTML,popup_html=`<div id="atlt-dialog-container">\n <div style="display:none;" id="atlt-dialog" title="Automatic Translation Progress">\n ${`<div class="atlt-settings">\n <form id="atlt-settings-form" method="post" action="#">\n <strong class="atlt-heading">Select Translation API</strong>\n <div class="inputGroup">\n <input class="inputEle" type="radio" id="ibm_api" \n ${iChecked} ${ifieldStatus} name="api_type" value="ibm">\n <label for="ibm_api">IBM Translate ${iHtml}</label>\n </div>\n\n <div class="inputGroup">\n <input class="inputEle" type="radio" id="yandex_api" \n ${yChecked} ${yfieldStatus} name="api_type" value="yandex">\n <label for="yandex_api">Yandex Translate ${yHtml}</label>\n </div>\n \n <div class="inputGroup ${gContCls}">\n <input class="inputEle" type="radio" id="google_api" \n name="api_type" value="google" ${gfieldStatus}>\n <label for="google_api">Google Translate ${gHtml}</label>\n </div>\n <div class="inputGroup ${mContCls}">\n <input class="inputEle" type="radio" id="microsoft_api" \n name="api_type" value="microsoft" ${mfieldStatus}>\n <label for="microsoft_api">Microsoft Translator ${mHtml}</label>\n <br/>\n <small style="display:inline-block;margin-left:24px;margin-top:8px;font-weight:bold;">(<a href="https://locotranslate.com/supported-languages/" target="_blank">View all supported languages list</a>)</small>\n </div>\n <br/>\n <strong class="atlt-heading">Select Content Type</strong>\n <div class="inputGroup">\n <input class="inputEle" type="radio" id="typeplain" checked="true" name="translationtype" value="plain">\n <label for="typeplain">${plainStringLbl}</label>\n </div>\n <div id="typehtmlWrapper" class="inputGroup ${contCls}">\n <input class="inputEle" type="radio" id="typehtml" name="translationtype" value="html" ${hfieldStatus}>\n <label for="typehtml">Translate HTML Strings (Supported by Yandex API v1) ${proLbl}\n </label>\n </br>\n <small style="display:inline-block;margin-left:24px;margin-top:8px;font-weight:bold;">(<a href="https://locotranslate.com/html-translation-languages-list/" target="_blank">List of languages with HTML support</a>)</small>\n </div>\n \n <br/>\n <fieldset>\n ${submitBtn}\n <img style="display:none;margin-left:10px;margin-top:-3px;" id="atlt_preloader" src="${preloaderImg}">\n </fieldset>\n </form>\n </div>`}\n <p><span class="translated-label">Translated</span>\n <span class="translated-text">0%</span></p>\n <div class="atlt-progress-bar-track">\n <div class="atlt-progress-bar-value">\n </div></div>\n <div class="atlt-final-message"></div>\n <button style="display:none;" class="atlt-ok button button-primary">OK</button>\n </div></div>`;$("body").append(popup_html)}function atlt_ajax_translation_request(data,type){let filteredArr=[];filteredArr=data.textToTranslateArr.map(item=>{if(void 0!==item.source)return item.source});const jsonData=JSON.stringify(filteredArr);return jQuery.ajax({url:ajaxurl,type:"POST",data:{action:data.endpoint,sourceLan:data.sourceLang,targetLan:data.targetLang,totalCharacters:TotalCharacters,requestChars:requestChars,nonce:data.nonce,strType:data.strType,apiType:data.apiType,data:jsonData},done:function(res){}})}template?(buttons.add=editable&®isterAddButton,buttons.del=editable&®isterDelButton):buttons.fuzzy=registerFuzzyButton,$("#loco-toolbar").find("button").each((function(i,el){var id=el.getAttribute("data-loco"),register=buttons[id];register&®ister(el,id)||$(el).hide()})),$(elForm).submit(noop),initSearchFilter(document.getElementById("loco-search")),editor.on("poUnsaved",(function(){window.onbeforeunload=onUnloadWarning})).on("poSave",(function(){updateStatus(),window.onbeforeunload=null})).on("poUpdate",updateStatus),messages.load(conf.podata),editor.load(messages),(locale=editor.targetLocale)?locale.isRTL()&&$(innerDiv).addClass("trg-rtl"):editor.unlock(),$(document).ready((function(){if(template)return;const locoRawData=conf.podata;function resetTransArr(tranArr,type){var resetStrs=[];return tranArr.map((function(item){if(void 0!==item.source&&void 0!==item.target)return"html"==type&&(isHTML(item.source)?item.target="":isAllowedChars(item.source)&&0==isPlacehodersChars(item.source)&&(item.target="")),"plain"==type&&(1==isPlacehodersChars(item.source)?item.target="":isHTML(item.source)||isAllowedChars(item.source)||(item.target="")),"all"==type&&(item.target=""),item}))}function resetTranslations(type){var resetArr=[];const saveBtn=$('[data-loco="save"]');void 0!==conf.podata&&(resetArr=resetTransArr(conf.podata,"plain"==type?"plain":"html"==type?"html":"all"),(messages=loco.po.init(locale).wrap(conf.powrap)).load(resetArr),editor.on("poUnsaved",(function(){window.onbeforeunload=onUnloadWarning})).on("poSave",(function(){updateStatus(),window.onbeforeunload=null})).on("poUpdate",updateStatus),editor.load(messages),saveBtn.addClass("button-primary loco-flagged").removeAttr("disabled"),updateStatus())}null!=locoRawData&&locoRawData.length>0&&addAutoTranslationBtn(),$(document).on("click","#cool-auto-translate-btn",(function(){$("#atlt-dialog").dialog({width:440,height:500})})),$("#typehtmlWrapper").hide(),$("input[name=api_type]").on("click",(function(){"google"==$(this).val()||"microsoft"==$(this).val()||"ibm"==$(this).val()?($("#typehtmlWrapper").hide(),$("#typeplain").attr("checked","checked")):$("#typehtmlWrapper").show()})),$("#atlt_reset_all").on("click",(function(){swal("What type of strings do you want to reset?",{dangerMode:!0,icon:"warning",confirmButtonColor:"#8CD4F5",buttons:{plain:{text:"Plain Text Strings",value:"plain",class:"danger"},html:{text:"HTML Strings",value:"html"},all:{text:"All Strings",value:"all"},cancel:{text:"Cancel",value:null,visible:!0,className:"",closeModal:!1}}}).then(value=>{switch(value){case"all":resetTranslations(value),swal("Done!","You have successfully reset all strings translations. Just close this popup & SAVE!","success");break;case"plain":resetTranslations(value),swal("Done!","You have successfully reset all plain text strings translations. Just close this popup & SAVE!","success");break;case"html":resetTranslations(value),swal("Done!","You have successfully reset all strings with HTML translations. Just close this popup & SAVE!","success");break;default:swal("Cancelled, Just close this popup!")}})})),$("#atlt-settings-form").submit((function(event){event.preventDefault();const user_type=ATLT.info.type;let strType=$("input[name='translationtype']:checked").val(),apiType=$("input[name='api_type']:checked").val(),mainBtn=$("#cool-auto-translate-btn");var thisBtn=$("#cool-auto-translate-start");let sourceApiKey="";var todayLimit=mainBtn.data("today-limit"),totalLimit=mainBtn.data("total-limit");let targetLang="";if("free"==user_type&&"html"==strType)return alert("HTML Translation Only Available in the PRO version"),!1;if("free"==user_type&&"google"==apiType)return alert("Google Translation Only Available in the PRO version"),!1;if("free"==user_type&&"microsoft"==apiType)return alert("Microsoft Translator Only Available in the PRO version"),!1;if((null==user_type||"pro"==user_type)&&null==ATLT.info.licenseKey)return alert("Please enter Your License Key"),!1;if(targetLang=1==conf.locale.lang?conf.locale.lang:getTargetLang(),"google"==apiType&&"html"==strType)return alert("Google Translate Only Support Plain Text Translation"),!1;if("microsoft"==apiType&&"html"==strType)return alert("Microsoft Translator Only Support Plain Text Translation"),!1;if("google"==apiType?("zh"==targetLang&&(targetLang=targetLang+"-"+conf.locale.region),sourceApiKey=ATLT.api_key.gApiKey):"microsoft"==apiType?("zh"==targetLang&&("CN"==conf.locale.region?targetLang+="-Hans":"TW"==conf.locale.region?targetLang+="-Hant":targetLang=targetLang+"-"+conf.locale.region),sourceApiKey=ATLT.api_key.mApiKey):sourceApiKey="ibm"==apiType?ATLT.api_key.ibmApiKey:ATLT.api_key.yApiKey,null!=locoRawData&&locoRawData.length>0&&""!=sourceApiKey){let plainStrArr=[],htmlStrArr=[],orgStrArr=[];orgStrArr=locoRawData;var countChars=0;if("plain"==strType?(plainStrArr=filterRawObject(locoRawData,"plain"),null!==plainStrArr&&plainStrArr.map((function(index){countChars+=index.source.length}))):(htmlStrArr=filterRawObject(locoRawData,"html"),null!==htmlStrArr&&plainStrArr.map((function(index){countChars+=index.length}))),null!==htmlStrArr||null!==plainStrArr)if(countChars>parseInt(todayLimit))alert("Your translation string are larger then available free limit.In order to extend limit Buy Pro license key");else{if("plain"==strType){if(0==plainStrArr.length)return $("#atlt-dialog").parent(".ui-dialog").hide(),mainBtn.attr("disabled","disabled"),alert("You have no untranslated plain strings"),void window.location.reload();dataObj={textToTranslateArr:plainStrArr,strType:"plain"}}else{if(0==htmlStrArr.length)return $("#atlt-dialog").parent(".ui-dialog").hide(),mainBtn.attr("disabled","disabled"),alert("You have no untranslated HTML strings"),void window.location.reload();dataObj={textToTranslateArr:htmlStrArr,strType:"html"}}dataObj.orgStrArr=orgStrArr,dataObj.thisBtn=thisBtn,dataObj.apiType=apiType,dataObj.targetLang=targetLang,dataObj.endpoint="google"==apiType||"microsoft"==apiType?"pro_autotranslate_handler":"free_autotranslate_handler",window.locoEditorStats.dataObj=dataObj,jQuery(document).trigger("atlt_run_translation"),thisBtn.val("Translating..."),mainBtn.text("Translating.."),$("#atlt_preloader").show()}}}))})),jQuery(document).on("atlt_run_translation",(function(){let textToTranslate=window.locoEditorStats.dataObj.textToTranslateArr,totalTranslated=window.locoEditorStats.totalTranslated;const nonce=ATLT.nonce,saveBtn=$('[data-loco="save"]'),orignalstringArr=window.locoEditorStats.dataObj.orgStrArr,targetLang=window.locoEditorStats.dataObj.targetLang;let indexRequest=50;if(""!=ATLT.api_key["atlt_index-per-request"]&&void 0!==ATLT.api_key["atlt_index-per-request"]&&(indexRequest=ATLT.api_key["atlt_index-per-request"]),"object"==typeof textToTranslate&&textToTranslate.length>=1){let translationO={textToTranslateArr:textToTranslate.slice(indexRequest),thisBtn:window.locoEditorStats.dataObj.thisBtn,strType:window.locoEditorStats.dataObj.strType,orgStrArr:window.locoEditorStats.dataObj.orgStrArr,apiType:window.locoEditorStats.dataObj.apiType,targetLang:targetLang,endpoint:window.locoEditorStats.dataObj.endpoint};window.locoEditorStats.dataObj=translationO;let data={sourceLang:"en",targetLang:targetLang,textToTranslateArr:textToTranslate.slice(0,indexRequest),orginalArr:orignalstringArr,thisBtn:window.locoEditorStats.dataObj.thisBtn,strType:window.locoEditorStats.dataObj.strType,apiType:window.locoEditorStats.dataObj.apiType,saveBtn:saveBtn,endpoint:window.locoEditorStats.dataObj.endpoint,nonce:nonce};textToTranslate.slice(0,indexRequest).map((function(value,index){TotalCharacters+=value.source.length,requestChars+=value.source.length})),atlt_translate(data)}})),updateStatus()}(window,jQuery);
|
1 |
+
!function(window,$){var TotalCharacters=0,HtmlStrings=0,requestChars=0;let event;document.createEvent("event").initEvent("atlt_run_translation"),createSettingsPopup(),$("#atlt-dialog .atlt-ok.button").on("click",(function(){localStorage.removeItem("unSavedString"),$("#atlt-dialog").parent(".ui-dialog").hide()}));var loco=window.locoScope,conf=window.locoConf,syncParams=null,saveParams=null,translator=loco.l10n,sprintf=loco.string.sprintf,locale=conf.locale,messages=loco.po.init(locale).wrap(conf.powrap),template=!locale,elForm=document.getElementById("loco-actions"),filePath=conf.popath,syncPath=conf.potpath,elFilesys=document.getElementById("loco-fs"),fsConnect=elFilesys&&loco.fs.init(elFilesys),readonly,editable=!conf.readonly,editor,saveButton,innerDiv=document.getElementById("loco-editor-inner");function doSyncAction(callback){function onSuccess(result){var info=[],doc=messages,exp=result.po,src=result.pot,pot=loco.po.init().load(exp),done=doc.merge(pot),nadd=done.add.length,ndel=done.del.length,t=translator;editor.load(doc),nadd||ndel?(src?info.push(sprintf(t._("Merged from %s"),src)):info.push(t._("Merged from source code")),nadd&&info.push(sprintf(t._n("1 new string added","%s new strings added",nadd),nadd)),ndel&&info.push(sprintf(t._n("1 obsolete string removed","%s obsolete strings removed",ndel),ndel)),$(innerDiv).trigger("poUnsaved",[]),updateStatus(),window.console&&debugMerge(console,done)):src?info.push(sprintf(t._("Already up to date with %s"),src)):info.push(t._("Already up to date with source code")),loco.notices.success(info.join(". ")),$(innerDiv).trigger("poMerge",[result]),callback&&callback()}loco.ajax.post("sync",syncParams,onSuccess,callback)}function debugMerge(console,result){for(var i=-1,t=result.add.length;++i<t;)console.log(" + "+result.add[i].source());for(i=-1,t=result.del.length;++i<t;)console.log(" - "+result.del[i].source())}function doSaveAction(callback){function onSuccess(result){callback&&callback(),editor.save(!0),$("#loco-po-modified").text(result.datetime||"[datetime error]")}saveParams.locale=String(messages.locale()||""),fsConnect&&fsConnect.applyCreds(saveParams),saveParams.data=String(messages),loco.ajax.post("save",saveParams,onSuccess,callback)}function saveIfDirty(){editor.dirty&&doSaveAction()}function onUnloadWarning(){return translator._("Your changes will be lost if you continue without saving")}function registerSaveButton(button){function disable(){button.disabled=!0}function enable(){button.disabled=!1}function think(){disable(),$(button).addClass("loco-loading")}function unthink(){enable(),$(button).removeClass("loco-loading")}return saveButton=button,editor.on("poUnsaved",(function(){enable(),$(button).addClass("button-primary loco-flagged")})).on("poSave",(function(){disable(),$(button).removeClass("button-primary loco-flagged")})),saveParams=$.extend({path:filePath},conf.project||{}),$(button).click((function(event){return event.preventDefault(),think(),doSaveAction(unthink),setTimeout((function(){location.reload()}),3500),!1})),!0}function registerSyncButton(button){var project=conf.project;if(project){function disable(){button.disabled=!0}function enable(){button.disabled=!1}function think(){disable(),$(button).addClass("loco-loading")}function unthink(){enable(),$(button).removeClass("loco-loading")}editor.on("poUnsaved",(function(){disable()})).on("poSave",(function(){enable()})),syncParams={bundle:project.bundle,domain:project.domain,type:template?"pot":"po",sync:syncPath||""},$(button).click((function(event){return event.preventDefault(),think(),doSyncAction(unthink),!1})),enable()}return!0}function registerFuzzyButton(button){var toggled=!1,enabled=!1;function redraw(message,state){var allowed=message&&message.translated(0)||!1;enabled!==allowed&&(button.disabled=!allowed,enabled=allowed),state!==toggled&&($(button)[state?"addClass":"removeClass"]("inverted"),toggled=state)}return editor.on("poSelected",(function(event,message){redraw(message,message&&message.fuzzy()||!1)})).on("poEmpty",(function(event,blank,message,pluralIndex){0===pluralIndex&&blank===enabled&&redraw(message,toggled)})).on("poFuzzy",(function(event,message,newState){redraw(message,newState)})),$(button).click((function(event){return event.preventDefault(),editor.fuzzy(!editor.fuzzy()),!1})),!0}function registerRevertButton(button){return editor.on("poUnsaved",(function(){button.disabled=!1})).on("poSave",(function(){button.disabled=!0})),$(button).click((function(event){return event.preventDefault(),location.reload(),!1})),!0}function registerInvisiblesButton(button){var $button=$(button);return button.disabled=!1,editor.on("poInvs",(function(event,state){$button[state?"addClass":"removeClass"]("inverted")})),$button.click((function(event){return event.preventDefault(),editor.setInvs(!editor.getInvs()),!1})),locoScope.tooltip.init($button),!0}function registerCodeviewButton(button){var $button=$(button);return button.disabled=!1,$button.click((function(event){event.preventDefault();var state=!editor.getMono();return editor.setMono(state),$button[state?"addClass":"removeClass"]("inverted"),!1})),locoScope.tooltip.init($button),!0}function registerAddButton(button){return button.disabled=!1,$(button).click((function(event){event.preventDefault();var i=1,baseid,msgid,regex=/(\d+)$/;for(msgid=baseid="New message";messages.get(msgid);)i=regex.exec(msgid)?Math.max(i,RegExp.$1):i,msgid=baseid+" "+ ++i;return editor.add(msgid),!1})),!0}function registerDelButton(button){return button.disabled=!1,$(button).click((function(event){return event.preventDefault(),editor.del(),!1})),!0}function registerDownloadButton(button,id){return button.disabled=!1,$(button).click((function(event){var form=button.form,path=filePath;return"binary"===id&&(path=path.replace(/\.po$/,".mo")),form.path.value=path,form.source.value=messages.toString(),!0})),!0}function noop(event){return event.preventDefault(),!1}function updateStatus(){var t=translator,stats=editor.stats(),total=stats.t,fuzzy=stats.f,empty=stats.u,stext=sprintf(t._n("1 string","%s strings",total),total.format(0)),extra=[];locale&&(stext=sprintf(t._("%s%% translated"),stats.p.replace("%",""))+", "+stext,fuzzy&&extra.push(sprintf(t._("%s fuzzy"),fuzzy.format(0))),empty&&extra.push(sprintf(t._("%s untranslated"),empty.format(0))),extra.length&&(stext+=" ("+extra.join(", ")+")")),$("#loco-po-status").text(stext),void 0===window.locoEditorStats?window.locoEditorStats={totalWords:stats.t,totalTranslated:stats.p}:(window.locoEditorStats.totalWords=stats.t,window.locoEditorStats.totalTranslated=stats.p)}function initSearchFilter(elSearch){function showValidFilter(numFound){$(elSearch.parentNode)[numFound||null==numFound?"removeClass":"addClass"]("invalid")}editor.searchable(loco.fulltext.init()),elSearch.disabled=!1,elSearch.value="";var listener=loco.watchtext(elSearch,(function(value){var numFound;showValidFilter(editor.filter(value,!0))}));editor.on("poFilter",(function(event,value,numFound){listener.val(value||""),showValidFilter(numFound)})).on("poMerge",(function(event,result){var value=listener.val();value&&editor.filter(value)}))}var resize=function(){function top(el,ancestor){for(var y=el.offsetTop||0;(el=el.offsetParent)&&el!==ancestor;)y+=el.offsetTop||0;return y}var fixHeight,minHeight=parseInt($(innerDiv).css("min-height")||0);return function(){var padBottom=20,topBanner=top(innerDiv,document.body),winHeight=window.innerHeight,setHeight=Math.max(minHeight,winHeight-topBanner-20);fixHeight!==setHeight&&(innerDiv.style.height=String(setHeight)+"px",fixHeight=setHeight)}}();resize(),$(window).resize(resize),innerDiv.innerHTML="",editor=loco.po.ed.init(innerDiv).localise(translator),loco.po.kbd.init(editor).add("save",saveIfDirty).enable("copy","clear","enter","next","prev","fuzzy","save","invis");var buttons={save:editable&®isterSaveButton,sync:editable&®isterSyncButton,revert:registerRevertButton,invs:registerInvisiblesButton,code:registerCodeviewButton,source:registerDownloadButton,binary:template?null:registerDownloadButton};function createEncodedString(allStringText){const queryString=allStringText.map(item=>"&text="+encodeURIComponent(item.source)).join(",");return queryString}function validLicenseKey(licenseKey){if(!(null!=licenseKey&&licenseKey.length>1))return!1;{let validKey;if(validate_pattern(licenseKey).length>1)return licenseKey}}function savedTimeInfo(statsObj){var info="";if(null!=statsObj&&void 0!==statsObj.time_saved){let timeSaved,totalChars;var info=`<div class="saved_time_wrapper" style="margin:10px 0px">\n <span style="border: 3px solid #14b75d;display: inline-block;padding: 3px;">\n Wahooo! You have saved your \n <strong>${statsObj.time_saved}</strong> \n via auto translating <strong>${statsObj.totalChars}</strong> \n characters using <strong> <br />\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></strong>\n </span></div>`}return info}function validate_pattern(str){let m;const regex=/^([A-Z0-9]{8})-([A-Z0-9]{8})-([A-Z0-9]{8})-([A-Z0-9]{8})$/gm;let saveMatch=[];for(;null!==(m=regex.exec(str));)m.index===regex.lastIndex&®ex.lastIndex++,m.forEach((match,groupIndex)=>{saveMatch.push(match)});return saveMatch}function getTargetLang(){return window.locoConf.locale.lang?window.locoConf.locale.lang:null}function atlt_translate(data){atlt_ajax_translation_request(data,"POST").success((function(resp,status,xhr){if(200==xhr.status&&null!=resp){const json_resp=JSON.parse(resp);let responseObj,apiProvider=window.locoEditorStats.dataObj.apiType;if(json_resp.error&&800==json_resp.error.code){let errorMsz=json_resp.error.message;return $("#atlt-dialog .atlt-final-message").html("<p style='color:red;margin:5px 2px;font-weight:bold;'>"+errorMsz+"</p>"),$("#atlt-dialog .atlt-ok.button").show(),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Error").attr("disabled","disabled"),setTimeout((function(){location.reload()}),4e3),!1}if(null==json_resp.translatedString||!json_resp.translatedString.length||200!=json_resp.code){let errorCode=json_resp.code,errorMsz=json_resp.error;return $("#atlt-dialog .atlt-final-message").html("<p style='color:red;margin:5px 2px;font-weight:bold;'>"+errorMsz+"</p>"),$("#atlt-dialog .atlt-ok.button").show(),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Error").attr("disabled","disabled"),setTimeout((function(){location.reload()}),4e3),!1}responseObj=json_resp.translatedString;let totalTranslated=window.locoEditorStats.totalTranslated,unSavedStr=[];if(void 0!==responseObj&&responseObj.length)for(i=0;i<responseObj.length;i++){var text=responseObj[i];if(void 0===data.textToTranslateArr[i])break;data.textToTranslateArr[i].target=text}let translatedStrArr=data.textToTranslateArr,Emptytargets=[],items;for(var x=0;x<translatedStrArr.length;++x)""!=translatedStrArr[x].target&&(Emptytargets[x]=translatedStrArr[x].source);items=localStorage.getItem("unSavedString")?JSON.parse(localStorage.getItem("unSavedString")):[];var unSavedStrArr=items.concat(Emptytargets);localStorage.setItem("unSavedString",JSON.stringify(unSavedStrArr)),(messages=loco.po.init(locale).wrap(conf.powrap)).load(conf.podata),editor.on("poUnsaved",(function(){window.onbeforeunload=onUnloadWarning})).on("poSave",(function(){updateStatus(),window.onbeforeunload=null})).on("poUpdate",updateStatus),editor.load(messages),data.saveBtn.addClass("button-primary loco-flagged").removeAttr("disabled"),updateStatus(),markUnsavedString(),requestChars=0,$("#atlt-dialog .translated-label").text("Translated"),$("#atlt-dialog .translated-text").text(window.locoEditorStats.totalTranslated),$("#atlt-dialog .atlt-progress-bar-value").width(window.locoEditorStats.totalTranslated);let saved_time_html=savedTimeInfo(json_resp.stats),finalHTML="<strong style='font-size:18px;display:inline-block;margin:5px auto;'>Translation Complete!</strong><br/>(Close this popup & Click <strong>Save</strong>).";switch(window.locoEditorStats.totalTranslated){case"0%":$("#atlt-dialog .translated-label").text("Translating..."),$("#atlt-dialog .translated-text").text("");break;case"100%":return data.thisBtn.hide(),$("#atlt_preloader").hide(),data.thisBtn.attr("disabled","disabled"),$("#cool-auto-translate-btn").text("Translated - SAVE NOW").attr("disabled","disabled"),$("#atlt-dialog .atlt-final-message").html(finalHTML+saved_time_html),void $("#atlt-dialog .atlt-ok.button").show()}for(var x=0;x<=Emptytargets.length;x++){var source=Emptytargets[x];jQuery("#po-list-tbody div[for='po-list-col-source'] div").filter((function(index){return jQuery(this).text()==source})).addClass("po-unsaved")}if(0==window.locoEditorStats.dataObj.textToTranslateArr.length)return data.thisBtn.val("Translated").attr("disabled","true"),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Translated - SAVE NOW").attr("disabled","disabled"),$("#atlt-dialog .atlt-final-message").html(finalHTML+saved_time_html),void $("#atlt-dialog .atlt-ok.button").show();jQuery(document).trigger("atlt_run_translation")}else data.thisBtn.hide("slow"),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Translation").attr("disabled","disabled"),$("#atlt-dialog .atlt-ok.button").show(),alert("Unable to make request to the server at the moment. Try again later.")})).fail((function(jqXHR){console.log(jqXHR),500!=jqXHR.status&&0!=jqXHR.status||(data.thisBtn.hide("slow"),$("#atlt_preloader").hide(),$("#cool-auto-translate-btn").text("Translation").attr("disabled","disabled"),$("#atlt-dialog .atlt-ok.button").show(),alert("Unable to make request to the server at the moment. Try again later."))}))}function filterSavedStrings(rawArray){return filterdArr=rawArray.filter((item,index)=>{if(""!=item.target&&void 0!==item.source&&""!=item.source)return!0})}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)&&("html"==filterType?!!isHTML(item.source)||!(!isAllowedChars(item.source)||0!=isPlacehodersChars(item.source)):!isHTML(item.source)&&(!!isPlacehodersChars(item.source)||!isSpecialChars(item.source)&&!item.source.includes("#")))})}function addAutoTranslationBtn(){$("#loco-toolbar").find("#cool-auto-translate-btn").length>0&&$("#loco-toolbar").find("#cool-auto-translate-btn").remove();const locoActions=$("#loco-toolbar").find("#loco-actions"),otherBtn='<button class="button has-icon icon-warn" id="atlt_reset_all">Reset Translations</button></fieldset>',allTranslated='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate" disabled>Translated</button></fieldset>';let savedStrings=filterSavedStrings(conf.podata),plainStrings=filterRawObject(conf.podata,"plain"),htmlStrings=filterRawObject(conf.podata,"html");const userType=ATLT.info.type;if(Array.isArray(plainStrings)&&plainStrings.length||Array.isArray(htmlStrings)&&htmlStrings.length){const inActiveBtn='<fieldset><button title="Add API key to enable this feature." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button> <a style="font-size:9px;display:block;margin-left:8px;" target="_blank" href="https://www.ibm.com/in-en/cloud/watson-language-translator/pricing">Get Free API Key</a></fieldset>',disabledBtn='<fieldset><button title="Buy PRO." id="cool-auto-translate-btn" disabled class="button has-icon icon-translate">Auto Translate</button><div style="max-width:320px; display:inline-block;margin-top: 4px;"><span style="font-size:12px;display:inline-block;margin-left:8px;">You have exceeded free translation limit. In order to extend the limit - <a target="_blank" style="font-size:14px;display:inline-block;margin-left:8px;" target="_blank" href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing">Buy Premium License</a></span></div></fieldset>',apiKey=ATLT.api_key.yApiKey,proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>',allowed=ATLT.info.allowed,today=ATLT.info.today,total=ATLT.info.total,aTodayChars=3e5,aTodayChar=1e6;if(null==ATLT||""==ATLT.api_key){if("free"==userType)return void locoActions.append(inActiveBtn);locoActions.append(proActiveBtn)}else if(""==ATLT.api_key.yApiKey&&""==ATLT.api_key.ibmApiKey){if("free"==userType)return void locoActions.append(inActiveBtn);locoActions.append(proActiveBtn)}else{if("no"==allowed&&"free"==userType)return void locoActions.append(disabledBtn);if(void 0!==today&&parseInt(today)>aTodayChars&&"free"==userType)return void locoActions.append(disabledBtn);if(void 0!==total&&parseInt(total)>aTodayChar&&"free"==userType)return void locoActions.append(disabledBtn);if("100%"!=window.locoEditorStats.totalTranslated&&window.locoEditorStats.totalWords>0)if("pro"==userType&&null!=ATLT.info.licenseKey&&validLicenseKey(ATLT.info.licenseKey))locoActions.append(proActiveBtn);else{if(null==today)var todayChars=aTodayChars;else var todayChars=aTodayChars-parseInt(today);var totalChars,freeBtn='<fieldset><button data-today-limit="'+todayChars+'" data-total-limit="'+(aTodayChar-parseInt(total))+'" id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(freeBtn)}else if(0==window.locoEditorStats.totalWords)return}}else locoActions.append(allTranslated);Array.isArray(savedStrings)&&savedStrings.length&&"pro"==userType&&null!=ATLT.info.licenseKey&&validLicenseKey(ATLT.info.licenseKey)&&"yes"==ATLT.info.proInstalled&&locoActions.append(otherBtn)}function markUnsavedString(){const unSavedString=JSON.parse(localStorage.getItem("unSavedString"));for(var x=0;x<=unSavedString.length;x++){var source=unSavedString[x];jQuery("#po-list-tbody div[for='po-list-col-source'] div").filter((function(index){return jQuery(this).text()==source})).addClass("po-unsaved")}}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 isAllowedChars(str){var rgex;return void 0!==str&&/[!@#$%^&*(),?":|<>]/g.test(str)}function isPlacehodersChars(str){var rgex;return void 0!==str&&/%s|%d/g.test(str)}function isContainChars(str){var rgex;return void 0!==str&&/[{}[]/g.test(str)}function atltFormatNumber(num){return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")}function createSettingsPopup(){let preloaderImg=extradata.preloader_path,gtPreviewImg=extradata.gt_preview;const userInfo=ATLT.info.type,yAC=ATLT.info.yAvailableChars,iAC=ATLT.info.iAvailableChars,licenseKey=ATLT.info.licenseKey,proInstalled=ATLT.info.proInstalled;let yfieldStatus="",ifieldStatus="",gfieldStatus="",mfieldStatus="",hfieldStatus="",htmlSupported="",contCls="",icontCls="",proLbl="",gContCls="",gHtml="",mContCls="",mHtml="",submitBtn="",yHtml="",iHtml="",yChecked='"',iChecked='checked="true"';if("free"==userInfo){let gAC=0;gfieldStatus="disabled",mfieldStatus="disabled",hfieldStatus="disabled",contCls="html-disabled",gContCls="g-disabled",mContCls="m-disabled",proLbl='<span class="atlt-pro-feature"><a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing" target="_blank" style="color:red;font-weight:bold;font-size:0.9em;" title="Only For Pro Users">PRO Only</a></span>',gHtml=proLbl+" ",mHtml=proLbl+" "}else if("no"==proInstalled)gfieldStatus="disabled",mfieldStatus="disabled",hfieldStatus="disabled",contCls="html-disabled",gContCls="g-disabled",mContCls="m-disabled",proLbl='<span style="color:red;font-weight:bold;font-size:0.9em;" class="atlt-pro-feature">Please Install PRO version</span>',gHtml=proLbl+" ",mHtml=proLbl+" ";else if(null!=ATLT.info.licenseKey&&validLicenseKey(ATLT.info.licenseKey)){if(""!=ATLT.api_key.gApiKey){let gAC=ATLT.info.gAvailableChars;void 0!==gAC&&gAC>1e4?gHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(gAC)+" Free Char. Available This Month)</span>":gAC<1e4&&(gHtml='<span class="used-chars" style="font-weight:bold;font-size:0.9em;">(You have consumed all free characters.)</span>')}else gfieldStatus="disabled",gContCls="g-disabled",gHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Google Translate API key)</span>';null!=ATLT.api_key.mApiKey&&""!=ATLT.api_key.mApiKey?(mAC=ATLT.info.mAvailableChars,void 0!==mAC&&mAC>1e4?mHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(mAC)+" Free Char. Available This Month)</span>":mAC<1e4&&(mHtml='<span class="used-chars" style="font-weight:bold;font-size:0.9em;">(You have consumed all free characters.)</span>')):(mfieldStatus="disabled",mContCls="m-disabled",mHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Microsoft Translator API key)</span>')}""!=ATLT.api_key.yApiKey?void 0!==yAC&&(yHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(yAC)+" Free Char. Available Monthly)</span>"):(yfieldStatus="disabled",yContCls="g-disabled",yChecked="",yHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Yandex Translate API v1 key)</span>'),""==ATLT.api_key.ibmApiKey||""==ATLT.info.ibm_url?(ifieldStatus="disabled",iContCls="g-disabled",iChecked="",iHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter IBM Translate API key/URL)</span>'):void 0!==iAC&&(iHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(iAC)+" Free Char. Available Monthly)</span>"),plainStringLbl="free"==userInfo?"Translate Plain Text Strings(No HTML/Special character supported)":"Translate Plain Text Strings",submitBtn=""!=ATLT.api_key.yApiKey||""!=ATLT.api_key.gApiKey||""!=ATLT.api_key.mApiKey||""!=ATLT.api_key.ibmApiKey?'<input type="submit" class="button has-icon icon-translate" value="Start Translation" id="cool-auto-translate-start">':'<button class="atlt-ok button button-primary">OK</button>';let settingsHTML,popup_html=`<div id="atlt-dialog-container">\n <div style="display:none;" id="atlt-dialog" title="Automatic Translation Progress">\n ${`<div class="atlt-settings">\n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Button<br/>(No API Key Required + Unlimited Translations!)</strong>\n <div class="inputGroup">\n <button id="atlt_gtranslate_btn" disabled="true" class="notranslate button button-primary">Google Translate</button>\n <br/><img src="${gtPreviewImg}" alt="google translate widget preview"><br/>\n ${proLbl}\n ✅ Available Inside Pro Version 1.1<br/><span style="font-size:11px;font-weight:bold;">(Release date:- 27 June, 2020)</span>\n </div>\n <hr/>\n <div class="atlt-settings">\n <form id="atlt-settings-form" method="post" action="#">\n <strong class="atlt-heading" style="margin:15px 0 10px;display:inline-block;">Translate Using A Translate API</strong>\n <div class="inputGroup">\n <input class="inputEle" type="radio" id="ibm_api" \n ${iChecked} ${ifieldStatus} name="api_type" value="ibm">\n <label for="ibm_api">IBM Translate ${iHtml}</label>\n </div>\n <div class="inputGroup">\n <input class="inputEle" type="radio" id="yandex_api" \n ${yChecked} ${yfieldStatus} name="api_type" value="yandex">\n <label for="yandex_api">Yandex Translate ${yHtml}</label>\n </div>\n \n <div class="inputGroup ${gContCls}">\n <input class="inputEle" type="radio" id="google_api" \n name="api_type" value="google" ${gfieldStatus}>\n <label for="google_api">Google Translate ${gHtml}</label>\n </div>\n <div class="inputGroup ${mContCls}">\n <input class="inputEle" type="radio" id="microsoft_api" \n name="api_type" value="microsoft" ${mfieldStatus}>\n <label for="microsoft_api">Microsoft Translator ${mHtml}</label>\n <br/>\n <small style="display:inline-block;margin-left:24px;margin-top:8px;font-weight:bold;">(<a href="https://locoaddon.com/supported-languages/" target="_blank">View all supported languages list</a>)</small>\n </div>\n <br/>\n <fieldset>\n ${submitBtn}\n <img style="display:none;margin-left:10px;margin-top:-3px;" id="atlt_preloader" src="${preloaderImg}">\n </fieldset>\n </form>\n </div>`}\n <p><span class="translated-label">Translated</span>\n <span class="translated-text">0%</span></p>\n <div class="atlt-progress-bar-track">\n <div class="atlt-progress-bar-value">\n </div></div>\n <div class="atlt-final-message"></div>\n <button style="display:none;" class="atlt-ok button button-primary">OK</button>\n </div></div>`;$("body").append(popup_html)}function atlt_ajax_translation_request(data,type){let filteredArr=[];filteredArr=data.textToTranslateArr.map(item=>{if(void 0!==item.source)return item.source});const jsonData=JSON.stringify(filteredArr);return jQuery.ajax({url:ajaxurl,type:"POST",data:{action:data.endpoint,sourceLan:data.sourceLang,targetLan:data.targetLang,totalCharacters:TotalCharacters,requestChars:requestChars,nonce:data.nonce,strType:data.strType,apiType:data.apiType,data:jsonData},done:function(res){}})}template?(buttons.add=editable&®isterAddButton,buttons.del=editable&®isterDelButton):buttons.fuzzy=registerFuzzyButton,$("#loco-toolbar").find("button").each((function(i,el){var id=el.getAttribute("data-loco"),register=buttons[id];register&®ister(el,id)||$(el).hide()})),$(elForm).submit(noop),initSearchFilter(document.getElementById("loco-search")),editor.on("poUnsaved",(function(){window.onbeforeunload=onUnloadWarning})).on("poSave",(function(){updateStatus(),window.onbeforeunload=null})).on("poUpdate",updateStatus),messages.load(conf.podata),editor.load(messages),(locale=editor.targetLocale)?locale.isRTL()&&$(innerDiv).addClass("trg-rtl"):editor.unlock(),$(document).ready((function(){if(template)return;const locoRawData=conf.podata;function resetTransArr(tranArr,type){var resetStrs=[];return tranArr.map((function(item){if(void 0!==item.source&&void 0!==item.target)return"html"==type&&(isHTML(item.source)?item.target="":isAllowedChars(item.source)&&0==isPlacehodersChars(item.source)&&(item.target="")),"plain"==type&&(1==isPlacehodersChars(item.source)?item.target="":isHTML(item.source)||isAllowedChars(item.source)||(item.target="")),"all"==type&&(item.target=""),item}))}function resetTranslations(type){var resetArr=[];const saveBtn=$('[data-loco="save"]');void 0!==conf.podata&&(resetArr=resetTransArr(conf.podata,"plain"==type?"plain":"html"==type?"html":"all"),(messages=loco.po.init(locale).wrap(conf.powrap)).load(resetArr),editor.on("poUnsaved",(function(){window.onbeforeunload=onUnloadWarning})).on("poSave",(function(){updateStatus(),window.onbeforeunload=null})).on("poUpdate",updateStatus),editor.load(messages),saveBtn.addClass("button-primary loco-flagged").removeAttr("disabled"),updateStatus())}null!=locoRawData&&locoRawData.length>0&&addAutoTranslationBtn(),$(document).on("click","#cool-auto-translate-btn",(function(){$("#atlt-dialog").dialog({width:440,height:500})})),$("#typehtmlWrapper").hide(),$("input[name=api_type]").on("click",(function(){"google"==$(this).val()||"microsoft"==$(this).val()||"ibm"==$(this).val()?($("#typehtmlWrapper").hide(),$("#typeplain").attr("checked","checked")):$("#typehtmlWrapper").show()})),$("#atlt_reset_all").on("click",(function(){swal("What type of strings do you want to reset?",{dangerMode:!0,icon:"warning",confirmButtonColor:"#8CD4F5",buttons:{plain:{text:"Plain Text Strings",value:"plain",class:"danger"},html:{text:"HTML Strings",value:"html"},all:{text:"All Strings",value:"all"},cancel:{text:"Cancel",value:null,visible:!0,className:"",closeModal:!1}}}).then(value=>{switch(value){case"all":resetTranslations(value),swal("Done!","You have successfully reset all strings translations. Just close this popup & SAVE!","success");break;case"plain":resetTranslations(value),swal("Done!","You have successfully reset all plain text strings translations. Just close this popup & SAVE!","success");break;case"html":resetTranslations(value),swal("Done!","You have successfully reset all strings with HTML translations. Just close this popup & SAVE!","success");break;default:swal("Cancelled, Just close this popup!")}})})),$("#atlt-settings-form").submit((function(event){event.preventDefault();const user_type=ATLT.info.type;let strType="plain",apiType=$("input[name='api_type']:checked").val(),mainBtn=$("#cool-auto-translate-btn");var thisBtn=$("#cool-auto-translate-start");let sourceApiKey="";var todayLimit=mainBtn.data("today-limit"),totalLimit=mainBtn.data("total-limit");let targetLang="";if("free"==user_type&&"google"==apiType)return alert("Google Translation Only Available in the PRO version"),!1;if("free"==user_type&&"microsoft"==apiType)return alert("Microsoft Translator Only Available in the PRO version"),!1;if((null==user_type||"pro"==user_type)&&null==ATLT.info.licenseKey)return alert("Please enter Your License Key"),!1;if(targetLang=1==conf.locale.lang?conf.locale.lang:getTargetLang(),"google"==apiType?("zh"==targetLang&&(targetLang=targetLang+"-"+conf.locale.region),sourceApiKey=ATLT.api_key.gApiKey):"microsoft"==apiType?("zh"==targetLang&&("CN"==conf.locale.region?targetLang+="-Hans":"TW"==conf.locale.region?targetLang+="-Hant":targetLang=targetLang+"-"+conf.locale.region),sourceApiKey=ATLT.api_key.mApiKey):sourceApiKey="ibm"==apiType?ATLT.api_key.ibmApiKey:ATLT.api_key.yApiKey,null!=locoRawData&&locoRawData.length>0&&""!=sourceApiKey){let plainStrArr=[],htmlStrArr=[],orgStrArr=[];orgStrArr=locoRawData;var countChars=0;if(plainStrArr=filterRawObject(locoRawData,"plain"),null!==plainStrArr&&plainStrArr.map((function(index){countChars+=index.source.length})),null!==htmlStrArr||null!==plainStrArr)if(countChars>parseInt(todayLimit))alert("Your translation string are larger then available free limit.In order to extend limit Buy Pro license key");else{if(0==plainStrArr.length)return $("#atlt-dialog").parent(".ui-dialog").hide(),mainBtn.attr("disabled","disabled"),alert("You have no untranslated plain strings"),void window.location.reload();dataObj={textToTranslateArr:plainStrArr,strType:"plain"},dataObj.orgStrArr=orgStrArr,dataObj.thisBtn=thisBtn,dataObj.apiType=apiType,dataObj.targetLang=targetLang,dataObj.endpoint="google"==apiType||"microsoft"==apiType?"pro_autotranslate_handler":"free_autotranslate_handler",window.locoEditorStats.dataObj=dataObj,jQuery(document).trigger("atlt_run_translation"),thisBtn.val("Translating..."),mainBtn.text("Translating.."),$("#atlt_preloader").show()}}}))})),jQuery(document).on("atlt_run_translation",(function(){let textToTranslate=window.locoEditorStats.dataObj.textToTranslateArr,totalTranslated=window.locoEditorStats.totalTranslated;const nonce=ATLT.nonce,saveBtn=$('[data-loco="save"]'),orignalstringArr=window.locoEditorStats.dataObj.orgStrArr,targetLang=window.locoEditorStats.dataObj.targetLang;let indexRequest=50;if(""!=ATLT.api_key["atlt_index-per-request"]&&void 0!==ATLT.api_key["atlt_index-per-request"]&&(indexRequest=ATLT.api_key["atlt_index-per-request"]),"object"==typeof textToTranslate&&textToTranslate.length>=1){let translationO={textToTranslateArr:textToTranslate.slice(indexRequest),thisBtn:window.locoEditorStats.dataObj.thisBtn,strType:window.locoEditorStats.dataObj.strType,orgStrArr:window.locoEditorStats.dataObj.orgStrArr,apiType:window.locoEditorStats.dataObj.apiType,targetLang:targetLang,endpoint:window.locoEditorStats.dataObj.endpoint};window.locoEditorStats.dataObj=translationO;let data={sourceLang:"en",targetLang:targetLang,textToTranslateArr:textToTranslate.slice(0,indexRequest),orginalArr:orignalstringArr,thisBtn:window.locoEditorStats.dataObj.thisBtn,strType:window.locoEditorStats.dataObj.strType,apiType:window.locoEditorStats.dataObj.apiType,saveBtn:saveBtn,endpoint:window.locoEditorStats.dataObj.endpoint,nonce:nonce};textToTranslate.slice(0,indexRequest).map((function(value,index){TotalCharacters+=value.source.length,requestChars+=value.source.length})),atlt_translate(data)}})),updateStatus()}(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.3.3 or lower to translate plugins and themes translation files into any language via fully automatic machine translations via IBM Watson Translate API.
|
5 |
-
Version:1.
|
6 |
License:GPL2
|
7 |
Text Domain:loco-translate-addon
|
8 |
Domain Path:languages
|
@@ -14,7 +14,7 @@ use LocoAutoTranslateAddon\Helpers\Helpers;
|
|
14 |
use LocoAutoTranslateAddon\Helpers\Atlt_rollback;
|
15 |
/**
|
16 |
* @package Loco Automatic Translate Addon
|
17 |
-
* @version 1.
|
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', '1.
|
27 |
|
28 |
class LocoAutoTranslate
|
29 |
{
|
@@ -43,12 +43,10 @@ class LocoAutoTranslate
|
|
43 |
add_action('wp_ajax_free_test_api_provider',array($this,'atlt_free_test_api_provider'));
|
44 |
add_action('init',array($this,'checkStatus'));
|
45 |
add_action('init',array($this,'updateSettings'));
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
}
|
50 |
}
|
51 |
-
|
52 |
/**
|
53 |
* This function hooked with AJAX to rollback loco translate plugin
|
54 |
*/
|
@@ -210,7 +208,7 @@ class LocoAutoTranslate
|
|
210 |
$apiKey = $api_key;
|
211 |
$keys_arr= get_option('atlt_register');
|
212 |
if(isset($keys_arr['atlt_ibm-translate-url'])){
|
213 |
-
$args['base'] =$keys_arr['atlt_ibm-translate-url'];
|
214 |
}
|
215 |
if(Helpers::ibmSLangList($targetLang)==false){
|
216 |
echo $this->errorResponse('IBM Translator Does not support this language');
|
@@ -287,12 +285,25 @@ class LocoAutoTranslate
|
|
287 |
|
288 |
if (current_user_can('activate_plugins')) {
|
289 |
$key=Helpers::getLicenseKey();
|
290 |
-
$url =esc_url( add_query_arg( 'license-key',$key , 'https://
|
291 |
$title = "Loco Automatic Translate Addon Pro";
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
}
|
297 |
}
|
298 |
|
@@ -359,7 +370,7 @@ class LocoAutoTranslate
|
|
359 |
|
360 |
$keys_arr= get_option('atlt_register');
|
361 |
if(isset($keys_arr['atlt_ibm-translate-url'])){
|
362 |
-
$args['base'] =$keys_arr['atlt_ibm-translate-url'];
|
363 |
}
|
364 |
$args['key'] = $apikey;
|
365 |
$ibm_obj= new ibmTranslator();
|
@@ -468,7 +479,6 @@ class LocoAutoTranslate
|
|
468 |
return $data;
|
469 |
}
|
470 |
|
471 |
-
|
472 |
/*
|
473 |
|------------------------------------------------------------------------
|
474 |
| Enqueue required JS file
|
@@ -481,16 +491,31 @@ class LocoAutoTranslate
|
|
481 |
wp_register_script( 'settings-sweet-alert', ATLT_URL.'assets/sweetalert/sweetalert.min.js',array('jquery'),false, true);
|
482 |
wp_register_script( 'test-api', ATLT_URL.'assets/js/api-testing.js', array('jquery','settings-sweet-alert'));
|
483 |
wp_register_script( 'atlt-rollback', ATLT_URL.'assets/js/atlt-rollback.js', array('jquery'));
|
484 |
-
|
485 |
-
|
486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
|
488 |
{
|
489 |
$data=array();
|
490 |
wp_enqueue_script('sweet-alert');
|
491 |
-
|
|
|
|
|
|
|
492 |
wp_enqueue_script('loco-js-editor');
|
493 |
-
|
494 |
$status=Helpers::atltVerification();
|
495 |
$data['api_key']['yApiKey']=Helpers::getAPIkey("yandex");
|
496 |
$data['info']['yAvailableChars']=Helpers::getAvailableChars("yandex");
|
@@ -538,10 +563,15 @@ class LocoAutoTranslate
|
|
538 |
}
|
539 |
}
|
540 |
$extraData['preloader_path']=ATLT_URL.'/assets/images/preloader.gif';
|
|
|
541 |
wp_localize_script('loco-js-editor', 'ATLT', $data);
|
542 |
wp_localize_script('loco-js-editor', 'extradata', $extraData);
|
543 |
-
|
544 |
-
|
|
|
|
|
|
|
|
|
545 |
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'loco-atlt')
|
546 |
{
|
547 |
wp_enqueue_script('settings-sweet-alert');
|
2 |
/*
|
3 |
Plugin Name:Automatic Translate Addon For Loco Translate
|
4 |
Description:Auto language translator add-on for Loco Translate official plugin version 2.3.3 or lower to translate plugins and themes translation files into any language via fully automatic machine translations via IBM Watson Translate API.
|
5 |
+
Version:1.9
|
6 |
License:GPL2
|
7 |
Text Domain:loco-translate-addon
|
8 |
Domain Path:languages
|
14 |
use LocoAutoTranslateAddon\Helpers\Atlt_rollback;
|
15 |
/**
|
16 |
* @package Loco Automatic Translate Addon
|
17 |
+
* @version 1.9
|
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', '1.9');
|
27 |
|
28 |
class LocoAutoTranslate
|
29 |
{
|
43 |
add_action('wp_ajax_free_test_api_provider',array($this,'atlt_free_test_api_provider'));
|
44 |
add_action('init',array($this,'checkStatus'));
|
45 |
add_action('init',array($this,'updateSettings'));
|
46 |
+
add_action('plugins_loaded', array($this,'include_files'));
|
|
|
|
|
47 |
}
|
48 |
}
|
49 |
+
|
50 |
/**
|
51 |
* This function hooked with AJAX to rollback loco translate plugin
|
52 |
*/
|
208 |
$apiKey = $api_key;
|
209 |
$keys_arr= get_option('atlt_register');
|
210 |
if(isset($keys_arr['atlt_ibm-translate-url'])){
|
211 |
+
$args['base'] =$keys_arr['atlt_ibm-translate-url'].'/v3/translate?version=2018-05-01';
|
212 |
}
|
213 |
if(Helpers::ibmSLangList($targetLang)==false){
|
214 |
echo $this->errorResponse('IBM Translator Does not support this language');
|
285 |
|
286 |
if (current_user_can('activate_plugins')) {
|
287 |
$key=Helpers::getLicenseKey();
|
288 |
+
$url =esc_url( add_query_arg( 'license-key',$key , 'https://locoaddon.com/data/download-plugin.php' ) );
|
289 |
$title = "Loco Automatic Translate Addon Pro";
|
290 |
+
|
291 |
+
if( class_exists( 'LocoAutoTranslateAddonPro' ) ){
|
292 |
+
// no further execution required
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
if( false == file_exists( WP_PLUGIN_DIR . '/loco-automatic-translate-addon-pro') ){
|
297 |
+
echo '<div class="error loco-pro-missing" style="border:2px solid;border-color:#dc3232;"><p>' .
|
298 |
+
sprintf('You are using <strong>%s</strong> license. Please also install and activate <strong>%s</strong> plugin to enjoy all premium featues and automatic premium updates.</p>
|
299 |
+
<p><a href="%s" target="_blank" title="%s" class="button button-primary"><strong>Download %s plugin</strong></a> and install it, you can also download it from <a href="https://locoaddon.com/my-account/downloads/" target="_blank">https://locoaddon.com/my-account/downloads/</a>',
|
300 |
+
esc_attr($title),esc_attr($title),esc_url($url),esc_attr($title),esc_attr($title)) . '.</p></div>';
|
301 |
+
}else{
|
302 |
+
echo '<div class="error loco-pro-missing" style="border:2px solid;border-color:#dc3232;"><p>' .
|
303 |
+
sprintf('You are using <strong>%s</strong> license. Please also activate <strong>%s</strong> plugin to enjoy all premium featues and automatic premium updates.</p>',
|
304 |
+
esc_attr($title),esc_attr($title)) . '</p></div>';
|
305 |
+
}
|
306 |
+
|
307 |
}
|
308 |
}
|
309 |
|
370 |
|
371 |
$keys_arr= get_option('atlt_register');
|
372 |
if(isset($keys_arr['atlt_ibm-translate-url'])){
|
373 |
+
$args['base'] =$keys_arr['atlt_ibm-translate-url'].'/v3/translate?version=2018-05-01';
|
374 |
}
|
375 |
$args['key'] = $apikey;
|
376 |
$ibm_obj= new ibmTranslator();
|
479 |
return $data;
|
480 |
}
|
481 |
|
|
|
482 |
/*
|
483 |
|------------------------------------------------------------------------
|
484 |
| Enqueue required JS file
|
491 |
wp_register_script( 'settings-sweet-alert', ATLT_URL.'assets/sweetalert/sweetalert.min.js',array('jquery'),false, true);
|
492 |
wp_register_script( 'test-api', ATLT_URL.'assets/js/api-testing.js', array('jquery','settings-sweet-alert'));
|
493 |
wp_register_script( 'atlt-rollback', ATLT_URL.'assets/js/atlt-rollback.js', array('jquery'));
|
494 |
+
if(Helpers::userType()=="free"){
|
495 |
+
wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_VERSION, true);
|
496 |
+
}else{
|
497 |
+
// if PRO version is installed then load assets
|
498 |
+
if(Helpers::proInstalled() && version_compare(ATLT_PRO_VERSION,'1.1', '>=')){
|
499 |
+
wp_register_script( 'loco-js-editor', ATLT_PRO_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_PRO_VERSION, true);
|
500 |
+
wp_register_script( 'loco-addon-custom', ATLT_PRO_URL.'assets/js/custom.js', array('loco-js-min-admin'),ATLT_PRO_VERSION, true);
|
501 |
+
wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.css',null,
|
502 |
+
ATLT_PRO_VERSION,'all');
|
503 |
+
}else{
|
504 |
+
wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_VERSION, true);
|
505 |
+
}
|
506 |
+
}
|
507 |
+
|
508 |
+
|
509 |
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
|
510 |
{
|
511 |
$data=array();
|
512 |
wp_enqueue_script('sweet-alert');
|
513 |
+
if(Helpers::userType()=="pro"){
|
514 |
+
wp_enqueue_script('loco-addon-custom');
|
515 |
+
wp_enqueue_style('loco-addon-custom-css');
|
516 |
+
}
|
517 |
wp_enqueue_script('loco-js-editor');
|
518 |
+
|
519 |
$status=Helpers::atltVerification();
|
520 |
$data['api_key']['yApiKey']=Helpers::getAPIkey("yandex");
|
521 |
$data['info']['yAvailableChars']=Helpers::getAvailableChars("yandex");
|
563 |
}
|
564 |
}
|
565 |
$extraData['preloader_path']=ATLT_URL.'/assets/images/preloader.gif';
|
566 |
+
$extraData['gt_preview']=ATLT_URL.'/assets/images/powered-by-google.png';
|
567 |
wp_localize_script('loco-js-editor', 'ATLT', $data);
|
568 |
wp_localize_script('loco-js-editor', 'extradata', $extraData);
|
569 |
+
|
570 |
+
if(Helpers::proInstalled() && version_compare(ATLT_PRO_VERSION,'1.1', '>=')){
|
571 |
+
wp_localize_script('loco-addon-custom', 'ATLT', $data);
|
572 |
+
wp_localize_script('loco-addon-custom', 'extradata', $extraData);
|
573 |
+
}
|
574 |
+
}
|
575 |
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'loco-atlt')
|
576 |
{
|
577 |
wp_enqueue_script('settings-sweet-alert');
|
includes/Core/class.settings-api.php
CHANGED
@@ -546,7 +546,7 @@ class Settings_API {
|
|
546 |
$license_key=get_option("LocoAutomaticTranslateAddonPro_lic_Key","");
|
547 |
$is_pro_active=is_plugin_active('loco-automatic-translate-addon-pro/loco-automatic-translate-addon-pro.php');
|
548 |
$license_type=get_option('atlt-type');
|
549 |
-
$download_url =esc_url( add_query_arg( 'license-key',$license_key , 'https://
|
550 |
|
551 |
if($license_type=='pro' && $license_key!= '' && $is_pro_active) {
|
552 |
?>
|
@@ -557,8 +557,8 @@ class Settings_API {
|
|
557 |
<p><a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" class="button button-primary">Submit Review! ★★★★★</a></p>
|
558 |
<h2>Important Notice & Links</h2>
|
559 |
<p>Plugin do not provide any free translation limit, it only provides setting panel to use third party translate APIs. All free characters translation limit provided by third party translate API providers - <strong>Google, Microsoft, IBM etc.</strong> You can grab translate API keys from these providers by following below instructions.</p>
|
560 |
-
<p><a style="font-size:12px" href="https://
|
561 |
-
<p><a style="font-size:12px" href="https://
|
562 |
<p><a style="font-size:12px" href="https://www.ibm.com/in-en/cloud/watson-language-translator/pricing" target="_blank" class="button button-secondary">Generate IBM Translate API Key</a></p>
|
563 |
<?php
|
564 |
}
|
@@ -574,7 +574,7 @@ class Settings_API {
|
|
574 |
<h2>Install Loco Automatic Translate Addon Pro</h2>
|
575 |
<p>Dear User,<br/><br/>You have activated pro license but didn't install <strong>Loco Automatic Translate Addon Pro</strong> plugin files. Please install and activate Loco Automatic Translate Addon Pro to enjoy all premium features.</p>
|
576 |
<p><a href="<?php echo $download_url ?>" target="_blank" class="button button-primary">Download Pro Plugin</a></p>
|
577 |
-
<p>or visit<br/><a href="https://
|
578 |
<?php
|
579 |
}
|
580 |
else {
|
@@ -588,11 +588,12 @@ class Settings_API {
|
|
588 |
<li>Microsoft Translate API.</li>
|
589 |
<li>Google & Microsoft automated translations are 70% better than IBM.</li>
|
590 |
<li>Google Translate provides 500,000 Char / Month free for automated translations while Microsoft Translate provides free 2,000,000 Char / Month</li>
|
|
|
591 |
<li>Reset translations with one click.</li>
|
592 |
<li>Regular updates with new features</li>
|
593 |
<li>Premium support via email.</li>
|
594 |
</ul>
|
595 |
-
<p><a href="https://
|
596 |
<?php
|
597 |
}
|
598 |
?>
|
546 |
$license_key=get_option("LocoAutomaticTranslateAddonPro_lic_Key","");
|
547 |
$is_pro_active=is_plugin_active('loco-automatic-translate-addon-pro/loco-automatic-translate-addon-pro.php');
|
548 |
$license_type=get_option('atlt-type');
|
549 |
+
$download_url =esc_url( add_query_arg( 'license-key',$license_key , 'https://locoaddon.com/data/download-plugin.php' ) );
|
550 |
|
551 |
if($license_type=='pro' && $license_key!= '' && $is_pro_active) {
|
552 |
?>
|
557 |
<p><a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" class="button button-primary">Submit Review! ★★★★★</a></p>
|
558 |
<h2>Important Notice & Links</h2>
|
559 |
<p>Plugin do not provide any free translation limit, it only provides setting panel to use third party translate APIs. All free characters translation limit provided by third party translate API providers - <strong>Google, Microsoft, IBM etc.</strong> You can grab translate API keys from these providers by following below instructions.</p>
|
560 |
+
<p><a style="font-size:12px" href="https://locoaddon.com/howto-generate-google-translate-api-key/" target="_blank" class="button button-secondary">Generate Google Translate API Key</a></p>
|
561 |
+
<p><a style="font-size:12px" href="https://locoaddon.com/how-to-generate-microsoft-translator-api-key/" target="_blank" class="button button-secondary">Generate Microsoft Translate API Key</a></p>
|
562 |
<p><a style="font-size:12px" href="https://www.ibm.com/in-en/cloud/watson-language-translator/pricing" target="_blank" class="button button-secondary">Generate IBM Translate API Key</a></p>
|
563 |
<?php
|
564 |
}
|
574 |
<h2>Install Loco Automatic Translate Addon Pro</h2>
|
575 |
<p>Dear User,<br/><br/>You have activated pro license but didn't install <strong>Loco Automatic Translate Addon Pro</strong> plugin files. Please install and activate Loco Automatic Translate Addon Pro to enjoy all premium features.</p>
|
576 |
<p><a href="<?php echo $download_url ?>" target="_blank" class="button button-primary">Download Pro Plugin</a></p>
|
577 |
+
<p>or visit<br/><a href="https://locoaddon.com/my-account/downloads/" target="_blank">https://locoaddon.com/my-account/downloads/</a></p>
|
578 |
<?php
|
579 |
}
|
580 |
else {
|
588 |
<li>Microsoft Translate API.</li>
|
589 |
<li>Google & Microsoft automated translations are 70% better than IBM.</li>
|
590 |
<li>Google Translate provides 500,000 Char / Month free for automated translations while Microsoft Translate provides free 2,000,000 Char / Month</li>
|
591 |
+
<li style="background:#fffb7a;">NEW - Use Google page translate button for unlimited translations without any API key.<br/>✅ Available Inside Pro Version 1.1<br/><span style="font-size:11px;font-weight:bold;">(Release date:- 27 June, 2020)</span></li>
|
592 |
<li>Reset translations with one click.</li>
|
593 |
<li>Regular updates with new features</li>
|
594 |
<li>Premium support via email.</li>
|
595 |
</ul>
|
596 |
+
<p><a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/" target="_blank" class="button button-primary">Buy Pro ($18 - $88)</a></p>
|
597 |
<?php
|
598 |
}
|
599 |
?>
|
includes/Core/class.settings-panel.php
CHANGED
@@ -149,7 +149,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
149 |
{
|
150 |
$apiKey= Helpers::getAPIkey("microsoft");
|
151 |
$lbl='Microsoft Translation';
|
152 |
-
$desc='<a target="_blank" href="https://
|
153 |
}else if($name=="ibm")
|
154 |
{
|
155 |
$keys_arr= get_option('atlt_register');
|
@@ -166,7 +166,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
166 |
{
|
167 |
$apiKey= Helpers::getAPIkey("google");
|
168 |
$lbl='Google Translation';
|
169 |
-
$desc= '<a target="_blank" href="https://
|
170 |
}else{
|
171 |
$apiKey= Helpers::getAPIkey("yandex");
|
172 |
$lbl='Yandex Translation';
|
@@ -213,7 +213,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
213 |
<tr>
|
214 |
<th><strong>FREE User</strong></th>
|
215 |
<th><a href="?page=loco-atlt-register">Enter License Key<br/><span>(Click Here!)</span></a></th>
|
216 |
-
<th><a target="_blank" href="https://
|
217 |
</tr>
|
218 |
</table>';
|
219 |
$a_per_day=300000;
|
@@ -315,7 +315,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
315 |
);
|
316 |
if(Helpers::userType()=="pro" && Helpers::proInstalled()==false) {
|
317 |
$key=Helpers::getLicenseKey();
|
318 |
-
$url =esc_url( add_query_arg( 'license-key',$key , 'https://
|
319 |
|
320 |
$settingArr[]=array(
|
321 |
'name' => $this->PREFIX.'install-pro',
|
@@ -384,7 +384,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
384 |
'id' => $this->PREFIX.'google-api-key-demo',
|
385 |
'class' => $this->PREFIX.'settings-field',
|
386 |
'label' => 'Enter Google Translate<br>API Key:',
|
387 |
-
'desc' =>'<a href="https://
|
388 |
'type' => 'html'
|
389 |
);
|
390 |
$settingArr[]=
|
@@ -393,7 +393,16 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
393 |
'id' => $this->PREFIX.'microsoft-api-key-demo',
|
394 |
'class' => $this->PREFIX.'settings-field',
|
395 |
'label' => 'Enter Microsoft Translator<br>API Key:',
|
396 |
-
'desc' =>'<a href="https://
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
'type' => 'html'
|
398 |
);
|
399 |
}
|
@@ -418,7 +427,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
418 |
'id' => $this->PREFIX.'supported-lang-list',
|
419 |
'class' => $this->PREFIX.'settings-field',
|
420 |
'label' => 'Supported Languages List',
|
421 |
-
'desc' =>'<a target="_blank" href="https://
|
422 |
'type' => 'html'
|
423 |
);
|
424 |
$settingArr[]=
|
@@ -574,7 +583,7 @@ if( !class_exists( 'Settings_Panel' ) ){
|
|
574 |
$HTML = '<div class="notice notice-warning inline is-dismissible"><p>'.$translation.'</p></div>';
|
575 |
echo $HTML;
|
576 |
}else if( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'loco-atlt' ){
|
577 |
-
$message = sprintf('Get a free API KEY from %s and save it below to enable the Auto Translation feature.','<a href="https://
|
578 |
$translation = __($message,'loco-translate-addon');
|
579 |
$HTML = '<div class="notice notice-warning inline is-dismissible"><p>'.$translation.'</p></div>';
|
580 |
echo $HTML;
|
149 |
{
|
150 |
$apiKey= Helpers::getAPIkey("microsoft");
|
151 |
$lbl='Microsoft Translation';
|
152 |
+
$desc='<a target="_blank" href="https://locoaddon.com/how-to-generate-microsoft-translator-api-key/">Check Microsoft Translator API key generation guide.</a>';
|
153 |
}else if($name=="ibm")
|
154 |
{
|
155 |
$keys_arr= get_option('atlt_register');
|
166 |
{
|
167 |
$apiKey= Helpers::getAPIkey("google");
|
168 |
$lbl='Google Translation';
|
169 |
+
$desc= '<a target="_blank" href="https://locoaddon.com/howto-generate-google-translate-api-key/">Check Google Translator API key generation guide.</a>';
|
170 |
}else{
|
171 |
$apiKey= Helpers::getAPIkey("yandex");
|
172 |
$lbl='Yandex Translation';
|
213 |
<tr>
|
214 |
<th><strong>FREE User</strong></th>
|
215 |
<th><a href="?page=loco-atlt-register">Enter License Key<br/><span>(Click Here!)</span></a></th>
|
216 |
+
<th><a target="_blank" href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing">Buy Pro License Key<br/><span>(Increase Translation Limit!)</span></a></th>
|
217 |
</tr>
|
218 |
</table>';
|
219 |
$a_per_day=300000;
|
315 |
);
|
316 |
if(Helpers::userType()=="pro" && Helpers::proInstalled()==false) {
|
317 |
$key=Helpers::getLicenseKey();
|
318 |
+
$url =esc_url( add_query_arg( 'license-key',$key , 'https://locoaddon.com/data/download-plugin.php' ) );
|
319 |
|
320 |
$settingArr[]=array(
|
321 |
'name' => $this->PREFIX.'install-pro',
|
384 |
'id' => $this->PREFIX.'google-api-key-demo',
|
385 |
'class' => $this->PREFIX.'settings-field',
|
386 |
'label' => 'Enter Google Translate<br>API Key:',
|
387 |
+
'desc' =>'<a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing" target="_blank"><img style="width:auto" src="'.ATLT_URL.'/assets/images/google-api.png" alt="Add Google Translate API Key"></a>',
|
388 |
'type' => 'html'
|
389 |
);
|
390 |
$settingArr[]=
|
393 |
'id' => $this->PREFIX.'microsoft-api-key-demo',
|
394 |
'class' => $this->PREFIX.'settings-field',
|
395 |
'label' => 'Enter Microsoft Translator<br>API Key:',
|
396 |
+
'desc' =>'<a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing" target="_blank"><img style="width:auto" src="'.ATLT_URL.'/assets/images/microsoft-api.png" alt="Add Microsoft Translator API Key"></a>',
|
397 |
+
'type' => 'html'
|
398 |
+
);
|
399 |
+
$settingArr[]=
|
400 |
+
array(
|
401 |
+
'name' => $this->PREFIX.'google-page-translate-button-demo',
|
402 |
+
'id' => $this->PREFIX.'google-page-translate-button-demo',
|
403 |
+
'class' => $this->PREFIX.'settings-field',
|
404 |
+
'label' => 'Google Translate Button<br>No API Key Required:<br/><img src='.ATLT_URL.'/assets/images/powered-by-google.png>',
|
405 |
+
'desc' =>'<a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing" target="_blank"><img style="width:auto" src="'.ATLT_URL.'/assets/images/google-translate-button.png" alt="Add Microsoft Translator API Key"><br/>✅ Available Inside Pro Version 1.1<br/><span style="font-size:11px;font-weight:bold;">(Release date:- 27 June, 2020)</span></a>',
|
406 |
'type' => 'html'
|
407 |
);
|
408 |
}
|
427 |
'id' => $this->PREFIX.'supported-lang-list',
|
428 |
'class' => $this->PREFIX.'settings-field',
|
429 |
'label' => 'Supported Languages List',
|
430 |
+
'desc' =>'<a target="_blank" href="https://locoaddon.com/supported-languages/">Click here to view All Supported Languages</a>',
|
431 |
'type' => 'html'
|
432 |
);
|
433 |
$settingArr[]=
|
583 |
$HTML = '<div class="notice notice-warning inline is-dismissible"><p>'.$translation.'</p></div>';
|
584 |
echo $HTML;
|
585 |
}else if( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'loco-atlt' ){
|
586 |
+
$message = sprintf('Get a free API KEY from %s and save it below to enable the Auto Translation feature.','<a href="https://cloud.ibm.com/registration" target="_blank">IBM Watson Language Translator</a>');
|
587 |
$translation = __($message,'loco-translate-addon');
|
588 |
$HTML = '<div class="notice notice-warning inline is-dismissible"><p>'.$translation.'</p></div>';
|
589 |
echo $HTML;
|
includes/Helpers/Helpers.php
CHANGED
@@ -28,7 +28,7 @@ class Helpers{
|
|
28 |
}
|
29 |
|
30 |
public static function proInstalled(){
|
31 |
-
if (
|
32 |
return true;
|
33 |
}else{
|
34 |
return false;
|
28 |
}
|
29 |
|
30 |
public static function proInstalled(){
|
31 |
+
if (defined('ATLT_PRO_FILE')) {
|
32 |
return true;
|
33 |
}else{
|
34 |
return false;
|
includes/Register/LocoAutomaticTranslateAddonPro.php
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
<?php
|
2 |
namespace LocoAutoTranslateAddon\Register;
|
3 |
-
|
|
|
4 |
require_once "LocoAutomaticTranslateAddonProBase.php";
|
5 |
class LocoAutomaticTranslateAddonPro {
|
6 |
public $plugin_file=__FILE__;
|
@@ -20,7 +21,7 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
|
|
20 |
add_action( 'admin_post_LocoAutomaticTranslateAddonPro_el_deactivate_license', [ $this, 'action_deactivate_license' ] );
|
21 |
//$this->licenselMessage=$this->mess;
|
22 |
update_option("atlt-type","pro");
|
23 |
-
|
24 |
|
25 |
}else{
|
26 |
if(!empty($licenseKey) && !empty($this->licenseMessage)){
|
@@ -35,7 +36,26 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
|
|
35 |
function SetAdminStyle() {
|
36 |
wp_register_style( "LocoAutomaticTranslateAddonProLic", plugins_url("style.css",$this->plugin_file),10);
|
37 |
wp_enqueue_style( "LocoAutomaticTranslateAddonProLic" );
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
function ActiveAdminMenu(){
|
40 |
add_submenu_page( 'loco',
|
41 |
'Loco Automatic Translate Addon Pro',
|
@@ -43,6 +63,48 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
|
|
43 |
'manage_options',
|
44 |
$this->slug,
|
45 |
array($this, 'Activated'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
function InactiveMenu() {
|
48 |
add_submenu_page( 'loco',
|
@@ -141,84 +203,97 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
|
|
141 |
<?php
|
142 |
}
|
143 |
?>
|
144 |
-
<p><?php _e("Enter your license key below to use more translate API providers and get premium support & features.",$this->slug);?></p>
|
145 |
<style>
|
146 |
table.loco-addon-license tr th, table.loco-addon-license tr td {
|
147 |
border: 1px solid #bbb;
|
148 |
padding: 12px;
|
149 |
text-align: center;
|
150 |
}
|
|
|
|
|
|
|
|
|
|
|
151 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
<table class="loco-addon-license">
|
153 |
<tr>
|
154 |
<th>Features</th>
|
155 |
<th>Free License</th>
|
156 |
<th>Premium License</th>
|
157 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
158 |
<tr>
|
159 |
-
<td><strong
|
160 |
-
<td
|
161 |
-
<td
|
162 |
</tr>
|
163 |
<tr>
|
164 |
<td>IBM API - free translation limit</td>
|
165 |
-
<td>1,000,000 char / month</td>
|
166 |
-
<td>1,000,000 char / month</td>
|
167 |
</tr>
|
168 |
<tr>
|
169 |
-
<td><strong
|
170 |
-
<td
|
171 |
-
<td
|
172 |
</tr>
|
173 |
<tr>
|
174 |
<td>Google API - free translation limit</td>
|
175 |
-
<td
|
176 |
-
<td>500,000 char / month</td>
|
177 |
</tr>
|
178 |
-
<td><strong
|
179 |
-
<td
|
180 |
-
<td
|
181 |
</tr>
|
182 |
<tr>
|
183 |
<td>Microsoft API - free translation limit</td>
|
184 |
-
<td
|
185 |
-
<td>2,000,000 char / month</td>
|
186 |
</tr>
|
187 |
<tr>
|
188 |
<td><strong>Reset Translations</strong></td>
|
189 |
-
<td
|
190 |
-
<td
|
191 |
-
</tr>
|
192 |
-
<tr>
|
193 |
-
<td>HTML Translation Support</td>
|
194 |
-
<td>Not Available</td>
|
195 |
-
<td>Not Available Now<br/>(Yandex API v1 deprecated)</td>
|
196 |
</tr>
|
197 |
<td><strong>Support</strong></td>
|
198 |
<td>WordPress Free Forum Support!<br/><strong>(Support Time: 7 – 10 days)</strong></td>
|
199 |
<td>Quick Support Via Email<br/><strong>contact@coolplugins.net</strong></td>
|
200 |
</tr>
|
201 |
</table>
|
202 |
-
<
|
203 |
-
<
|
204 |
-
<
|
205 |
-
<br/>
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
</div>
|
210 |
-
<div class="el-license-field">
|
211 |
-
<label for="el_license_key"><?php _e("Email Address",$this->slug);?></label>
|
212 |
-
<?php
|
213 |
-
$purchaseEmail = get_option( "LocoAutomaticTranslateAddonPro_lic_email", get_bloginfo( 'admin_email' ));
|
214 |
-
?>
|
215 |
-
<input type="text" class="regular-text code" name="el_license_email" size="50" value="<?php echo sanitize_email($purchaseEmail); ?>" placeholder="" required="required">
|
216 |
-
<div><small><?php _e("✅ I agree to share my purchase code and email for plugin verification and to receive future updates notifications!",$this->slug);?></small></div>
|
217 |
</div>
|
218 |
-
|
219 |
-
|
220 |
-
<?php submit_button('Activate'); ?>
|
221 |
-
</div>
|
222 |
</div>
|
223 |
</form>
|
224 |
<?php
|
1 |
<?php
|
2 |
namespace LocoAutoTranslateAddon\Register;
|
3 |
+
use LocoAutoTranslateAddon\Helpers\Atlt_rollback;
|
4 |
+
|
5 |
require_once "LocoAutomaticTranslateAddonProBase.php";
|
6 |
class LocoAutomaticTranslateAddonPro {
|
7 |
public $plugin_file=__FILE__;
|
21 |
add_action( 'admin_post_LocoAutomaticTranslateAddonPro_el_deactivate_license', [ $this, 'action_deactivate_license' ] );
|
22 |
//$this->licenselMessage=$this->mess;
|
23 |
update_option("atlt-type","pro");
|
24 |
+
add_action('wp_ajax_loco_install_pro', array($this, 'loco_install_pro'));
|
25 |
|
26 |
}else{
|
27 |
if(!empty($licenseKey) && !empty($this->licenseMessage)){
|
36 |
function SetAdminStyle() {
|
37 |
wp_register_style( "LocoAutomaticTranslateAddonProLic", plugins_url("style.css",$this->plugin_file),10);
|
38 |
wp_enqueue_style( "LocoAutomaticTranslateAddonProLic" );
|
39 |
+
}
|
40 |
+
|
41 |
+
function loco_install_pro(){
|
42 |
+
$pass = (isset( $_POST['pass'] ) && !empty( $_POST['pass'] )) ? $_POST['pass'] : null;
|
43 |
+
if( $pass === null || false == wp_verify_nonce( $pass, 'loco-pro-activation-nonce' )){
|
44 |
+
die( array('response'=>'500','message'=>'Nonce Verification falied') );
|
45 |
+
}
|
46 |
+
$hash = isset($_POST['hash']) ? $_POST['hash'] : null;
|
47 |
+
if( !empty( $hash ) ){
|
48 |
+
require_once ATLT_PATH . 'includes/Helpers/Atlt_rollback.php';
|
49 |
+
$request = new Atlt_rollback();
|
50 |
+
$response = $request->install( 'https://locoaddon.com/data/download-plugin.php?license-key=' . $hash );
|
51 |
+
}
|
52 |
+
if( file_exists( WP_PLUGIN_DIR . '/loco-automatic-translate-addon-pro')==true ){
|
53 |
+
activate_plugin( 'loco-automatic-translate-addon-pro/loco-automatic-translate-addon-pro.php' );
|
54 |
+
die( json_encode( array('response'=>'200','message'=>'Loco Automatic Translate Addon Pro - Installed Successfully!')) );
|
55 |
+
}else{
|
56 |
+
die( json_encode( array('response'=>'500','message'=>'Loco Automatic Translate Addon Pro - Installation failed! Try downloading manually.')) );
|
57 |
+
}
|
58 |
+
}
|
59 |
function ActiveAdminMenu(){
|
60 |
add_submenu_page( 'loco',
|
61 |
'Loco Automatic Translate Addon Pro',
|
63 |
'manage_options',
|
64 |
$this->slug,
|
65 |
array($this, 'Activated'));
|
66 |
+
|
67 |
+
if( class_exists( 'LocoAutoTranslateAddonPro' ) ){
|
68 |
+
// no further execution required
|
69 |
+
return;
|
70 |
+
}
|
71 |
+
if( false == file_exists( WP_PLUGIN_DIR . '/loco-automatic-translate-addon-pro') &&
|
72 |
+
isset( $_GET['page'] ) && $_GET['page'] == "loco-atlt-register" ){
|
73 |
+
|
74 |
+
add_action('admin_footer', function(){
|
75 |
+
$hash_key = get_option( 'LocoAutomaticTranslateAddonPro_lic_Key' ,false);
|
76 |
+
$pass = wp_create_nonce('loco-pro-activation-nonce');
|
77 |
+
$url = admin_url( 'admin-ajax.php' );
|
78 |
+
$script = '
|
79 |
+
<script>
|
80 |
+
jQuery(document).ready(function($){
|
81 |
+
$(".error.loco-pro-missing").hide();
|
82 |
+
$.ajax({
|
83 |
+
type:"POST",
|
84 |
+
url:"'.$url.'",
|
85 |
+
data:{action:"loco_install_pro",hash:"'.$hash_key.'",pass:"'.$pass.'"},
|
86 |
+
complete:function(res){
|
87 |
+
console.log(res);
|
88 |
+
if( res.status == 200 ){
|
89 |
+
console.log( res.message )
|
90 |
+
$("#activating-loco-pro-response").text("Pro features activated successfully!");
|
91 |
+
window.setTimeout(function(){
|
92 |
+
$("#activating-loco-pro-response").fadeOut(400);
|
93 |
+
},1500);
|
94 |
+
}else{
|
95 |
+
console.log( res.message )
|
96 |
+
}
|
97 |
+
}
|
98 |
+
})
|
99 |
+
});
|
100 |
+
</script>
|
101 |
+
<div id="activating-loco-pro-response">
|
102 |
+
<span> Please wait while we are activating pro features for you</span>
|
103 |
+
</div>
|
104 |
+
';
|
105 |
+
echo $script;
|
106 |
+
} );
|
107 |
+
}
|
108 |
}
|
109 |
function InactiveMenu() {
|
110 |
add_submenu_page( 'loco',
|
203 |
<?php
|
204 |
}
|
205 |
?>
|
|
|
206 |
<style>
|
207 |
table.loco-addon-license tr th, table.loco-addon-license tr td {
|
208 |
border: 1px solid #bbb;
|
209 |
padding: 12px;
|
210 |
text-align: center;
|
211 |
}
|
212 |
+
table.loco-addon-license tr td strong img {
|
213 |
+
height: 28px;
|
214 |
+
width: auto;
|
215 |
+
vertical-align: middle;
|
216 |
+
}
|
217 |
</style>
|
218 |
+
<!--Enter License Key Here START-->
|
219 |
+
<div class="el-license-field">
|
220 |
+
<label for="el_license_key"><?php _e("Enter License code",$this->slug);?></label>
|
221 |
+
<input type="text" class="regular-text code" name="el_license_key" size="50" placeholder="xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx" required="required">
|
222 |
+
</div>
|
223 |
+
<div class="el-license-field">
|
224 |
+
<label for="el_license_key"><?php _e("Email Address",$this->slug);?></label>
|
225 |
+
<?php
|
226 |
+
$purchaseEmail = get_option( "LocoAutomaticTranslateAddonPro_lic_email", get_bloginfo( 'admin_email' ));
|
227 |
+
?>
|
228 |
+
<input type="text" class="regular-text code" name="el_license_email" size="50" value="<?php echo sanitize_email($purchaseEmail); ?>" placeholder="" required="required">
|
229 |
+
<div><small><?php _e("✅ I agree to share my purchase code and email for plugin verification and to receive future updates notifications!",$this->slug);?></small></div>
|
230 |
+
</div>
|
231 |
+
<div class="el-license-active-btn">
|
232 |
+
<?php wp_nonce_field( 'el-license' ); ?>
|
233 |
+
<?php submit_button('Activate'); ?>
|
234 |
+
</div>
|
235 |
+
<!--Enter License Key Here END-->
|
236 |
+
<h3>Compare Free vs Pro (<a href='https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Premium License Key</a>)</h3>
|
237 |
<table class="loco-addon-license">
|
238 |
<tr>
|
239 |
<th>Features</th>
|
240 |
<th>Free License</th>
|
241 |
<th>Premium License</th>
|
242 |
</tr>
|
243 |
+
<tr style="background:#fffb7a;font-weight: bold;">
|
244 |
+
<td>**NEW**<br/>Google Translate Button Support<br/><span>(No API Key Required)<br/>+<br/>(Unlimited Translations)</span><br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-google.png' ?>"/></td>
|
245 |
+
<td>❌ Not Available</td>
|
246 |
+
<td>✅ Available Inside Pro Version 1.1<br/><span style="font-size:11px;font-weight:bold;">(Release date:- 27 June, 2020)</span></td>
|
247 |
+
</tr>
|
248 |
<tr>
|
249 |
+
<td><strong><img src="<?php echo ATLT_URL.'/assets/images/ibm-translate.png' ?>"/> IBM Watson Language Translator API</strong></td>
|
250 |
+
<td>✅ Available</td>
|
251 |
+
<td>✅ Available</td>
|
252 |
</tr>
|
253 |
<tr>
|
254 |
<td>IBM API - free translation limit</td>
|
255 |
+
<td>1,000,000 char / month<br/><span style="font-size:11px;font-weight:bold;">(Provided by API Provider)</span></td>
|
256 |
+
<td>1,000,000 char / month<br/><span style="font-size:11px;font-weight:bold;">(Provided by API Provider)</span></td>
|
257 |
</tr>
|
258 |
<tr>
|
259 |
+
<td><strong><img src="<?php echo ATLT_URL.'/assets/images/google-translate.png' ?>"/> Google Translate API Support</strong></td>
|
260 |
+
<td>❌ Not Available</td>
|
261 |
+
<td>✅ Available</td>
|
262 |
</tr>
|
263 |
<tr>
|
264 |
<td>Google API - free translation limit</td>
|
265 |
+
<td>❌ Not Available</td>
|
266 |
+
<td>500,000 char / month<br/><span style="font-size:11px;font-weight:bold;">(Provided by API Provider)</span></td>
|
267 |
</tr>
|
268 |
+
<td><strong><img src="<?php echo ATLT_URL.'/assets/images/microsoft-translate.png' ?>"/> Microsoft Translator API Support</strong></td>
|
269 |
+
<td>❌ Not Available</td>
|
270 |
+
<td>✅ Available</td>
|
271 |
</tr>
|
272 |
<tr>
|
273 |
<td>Microsoft API - free translation limit</td>
|
274 |
+
<td>❌ Not Available</td>
|
275 |
+
<td>2,000,000 char / month<br/><span style="font-size:11px;font-weight:bold;">(Provided by API Provider)</span></td>
|
276 |
</tr>
|
277 |
<tr>
|
278 |
<td><strong>Reset Translations</strong></td>
|
279 |
+
<td>❌ Not Available</td>
|
280 |
+
<td>✅ Available</td>
|
|
|
|
|
|
|
|
|
|
|
281 |
</tr>
|
282 |
<td><strong>Support</strong></td>
|
283 |
<td>WordPress Free Forum Support!<br/><strong>(Support Time: 7 – 10 days)</strong></td>
|
284 |
<td>Quick Support Via Email<br/><strong>contact@coolplugins.net</strong></td>
|
285 |
</tr>
|
286 |
</table>
|
287 |
+
<div>
|
288 |
+
<strong style="color:#e00b0b;">*Important Points</strong>
|
289 |
+
<ol>
|
290 |
+
<li>Free characters translation limit only provided by Translate API providers, e.g. - Google, Microsoft, IBM etc.<br/>You need to grab translate API keys from their respective API platforms. Plugin does not provide any<br/>free characters limit for automatic translations.</li>
|
291 |
+
<li>If any translation API provider stop providing free translations or translation API anytime in future.<br/>In that case plugin will not support that translation API provider.</li>
|
292 |
+
<li>Currently automatic translate providers do not support HTML and special characters translations.<br/>So plugin will not translate any string that contains HTML or special characters.</li>
|
293 |
+
</ol>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
</div>
|
295 |
+
<br/>
|
296 |
+
<a class="button button-primary" href='https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Premium License Key</a>
|
|
|
|
|
297 |
</div>
|
298 |
</form>
|
299 |
<?php
|
includes/Register/style.css
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
.el-license-container .el-license-field {
|
3 |
display: block;
|
4 |
margin-bottom: 15px;
|
@@ -24,14 +23,18 @@
|
|
24 |
background: #fff;
|
25 |
border-radius: 4px;
|
26 |
}
|
27 |
-
|
|
|
|
|
28 |
background: rgba(220, 50, 50, 0.11);
|
29 |
margin: 0;
|
30 |
}
|
31 |
-
|
|
|
32 |
margin-top: 0;
|
33 |
font-size: 30px;
|
34 |
}
|
|
|
35 |
.el-license-info li {
|
36 |
list-style: none;
|
37 |
padding: 0;
|
@@ -50,16 +53,31 @@
|
|
50 |
right: 2px;
|
51 |
}
|
52 |
|
53 |
-
.el-license-valid,
|
|
|
54 |
padding: 0px 5px 2px;
|
55 |
color: #fff;
|
56 |
background-color: #8fcc77;
|
57 |
border-radius: 3px;
|
58 |
}
|
|
|
59 |
.el-license-invalid {
|
60 |
background-color: #f44336;
|
61 |
}
|
|
|
62 |
.el-license-key {
|
63 |
font-weight: 700;
|
64 |
opacity: 0.8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
|
|
1 |
.el-license-container .el-license-field {
|
2 |
display: block;
|
3 |
margin-bottom: 15px;
|
23 |
background: #fff;
|
24 |
border-radius: 4px;
|
25 |
}
|
26 |
+
|
27 |
+
.el-license-container .notice-error,
|
28 |
+
.el-license-container div.error {
|
29 |
background: rgba(220, 50, 50, 0.11);
|
30 |
margin: 0;
|
31 |
}
|
32 |
+
|
33 |
+
.el-license-container .el-license-title {
|
34 |
margin-top: 0;
|
35 |
font-size: 30px;
|
36 |
}
|
37 |
+
|
38 |
.el-license-info li {
|
39 |
list-style: none;
|
40 |
padding: 0;
|
53 |
right: 2px;
|
54 |
}
|
55 |
|
56 |
+
.el-license-valid,
|
57 |
+
.el-license-invalid {
|
58 |
padding: 0px 5px 2px;
|
59 |
color: #fff;
|
60 |
background-color: #8fcc77;
|
61 |
border-radius: 3px;
|
62 |
}
|
63 |
+
|
64 |
.el-license-invalid {
|
65 |
background-color: #f44336;
|
66 |
}
|
67 |
+
|
68 |
.el-license-key {
|
69 |
font-weight: 700;
|
70 |
opacity: 0.8;
|
71 |
+
}
|
72 |
+
|
73 |
+
div#activating-loco-pro-response {
|
74 |
+
position: fixed;
|
75 |
+
margin: 0 auto;
|
76 |
+
display: block;
|
77 |
+
top: 50%;
|
78 |
+
left: 40%;
|
79 |
+
color: black;
|
80 |
+
font-size: 21px;
|
81 |
+
background: #f5f5f5;
|
82 |
+
padding: 45px;
|
83 |
}
|
includes/ReviewNotice/class.review-notice.php
CHANGED
@@ -22,8 +22,6 @@ if (!class_exists('ALTLReviewNotice')) {
|
|
22 |
* @return void
|
23 |
*/
|
24 |
public function atlt_load_script() {
|
25 |
-
wp_register_script( 'atlt-feedback-notice-script', ATLT_URL. 'assets/js/atlt-admin-feedback-notice.js', array( 'jquery' ),null, true );
|
26 |
-
wp_enqueue_script( 'atlt-feedback-notice-script' );
|
27 |
wp_register_style( 'atlt-feedback-notice-styles',ATLT_URL.'assets/css/atlt-admin-feedback-notice.css' );
|
28 |
wp_enqueue_style( 'atlt-feedback-notice-styles' );
|
29 |
}
|
@@ -35,7 +33,6 @@ if (!class_exists('ALTLReviewNotice')) {
|
|
35 |
}
|
36 |
// admin notice
|
37 |
public function atlt_admin_notice_for_reviews(){
|
38 |
-
|
39 |
if( !current_user_can( 'update_plugins' ) ){
|
40 |
return;
|
41 |
}
|
@@ -90,7 +87,7 @@ if (!class_exists('ALTLReviewNotice')) {
|
|
90 |
</div>
|
91 |
</div>';
|
92 |
|
93 |
-
|
94 |
$wrap_cls,
|
95 |
$img_path,
|
96 |
$p_name,
|
@@ -103,8 +100,71 @@ if (!class_exists('ALTLReviewNotice')) {
|
|
103 |
$not_like_it_text//10
|
104 |
|
105 |
);
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
} //class end
|
110 |
|
22 |
* @return void
|
23 |
*/
|
24 |
public function atlt_load_script() {
|
|
|
|
|
25 |
wp_register_style( 'atlt-feedback-notice-styles',ATLT_URL.'assets/css/atlt-admin-feedback-notice.css' );
|
26 |
wp_enqueue_style( 'atlt-feedback-notice-styles' );
|
27 |
}
|
33 |
}
|
34 |
// admin notice
|
35 |
public function atlt_admin_notice_for_reviews(){
|
|
|
36 |
if( !current_user_can( 'update_plugins' ) ){
|
37 |
return;
|
38 |
}
|
87 |
</div>
|
88 |
</div>';
|
89 |
|
90 |
+
$output= sprintf($html,
|
91 |
$wrap_cls,
|
92 |
$img_path,
|
93 |
$p_name,
|
100 |
$not_like_it_text//10
|
101 |
|
102 |
);
|
103 |
+
|
104 |
+
$scripts='<script>jQuery(document).ready(function ($) {
|
105 |
+
$(".atlt_dismiss_notice").on("click", function (event) {
|
106 |
+
var $this = $(this);
|
107 |
+
var wrapper=$this.parents(".atlt-feedback-notice-wrapper");
|
108 |
+
var ajaxURL=wrapper.data("ajax-url");
|
109 |
+
var ajaxCallback=wrapper.data("ajax-callback");
|
110 |
+
|
111 |
+
$.post(ajaxURL, { "action":ajaxCallback }, function( data ) {
|
112 |
+
wrapper.slideUp("fast");
|
113 |
+
}, "json");
|
114 |
+
|
115 |
+
});
|
116 |
+
});</script>';
|
117 |
+
$styles='<style>
|
118 |
+
.atlt-feedback-notice-wrapper.notice.notice-info.is-dismissible {
|
119 |
+
padding: 5px;
|
120 |
+
margin: 10px 20px 10px 0;
|
121 |
+
border-left-color: #4aba4a;
|
122 |
+
}
|
123 |
+
|
124 |
+
.atlt-feedback-notice-wrapper .logo_container {
|
125 |
+
width: 80px;
|
126 |
+
display: inline-block;
|
127 |
+
margin-right: 10px;
|
128 |
+
vertical-align: top;
|
129 |
+
}
|
130 |
+
|
131 |
+
.atlt-feedback-notice-wrapper .logo_container img {
|
132 |
+
width: 100%;
|
133 |
+
height: auto;
|
134 |
+
}
|
135 |
+
|
136 |
+
.atlt-feedback-notice-wrapper .message_container {
|
137 |
+
width: calc(100% - 120px);
|
138 |
+
display: inline-block;
|
139 |
+
margin: 0;
|
140 |
+
vertical-align: top;
|
141 |
+
}
|
142 |
+
.atlt-feedback-notice-wrapper ul li {
|
143 |
+
float: left;
|
144 |
+
margin: 0px 5px;
|
145 |
+
}
|
146 |
+
|
147 |
+
.atlt-feedback-notice-wrapper ul li.already_rated a:before {
|
148 |
+
color: #cc0000;
|
149 |
+
content: "\f153";
|
150 |
+
font: normal 16px/20px dashicons;
|
151 |
+
display: inline-block;
|
152 |
+
vertical-align: middle;
|
153 |
+
margin-right: 4px;
|
154 |
+
height: 22px;
|
155 |
+
}
|
156 |
+
.atlt-feedback-notice-wrapper ul li.already_rated a[title="Not Interested"] {
|
157 |
+
position: absolute;
|
158 |
+
right: 5px;
|
159 |
+
top: 5px;
|
160 |
+
z-index: 9;
|
161 |
+
}
|
162 |
+
.clrfix {
|
163 |
+
clear: both;
|
164 |
+
}
|
165 |
+
</style>';
|
166 |
+
return $output.$scripts.$styles;
|
167 |
+
}
|
168 |
|
169 |
} //class end
|
170 |
|
readme.txt
CHANGED
@@ -26,7 +26,7 @@ This addon provides support to use IBM Watson Translator API for free users and
|
|
26 |
* You can automatic translate upto **1,000,000 characters** monthly free of cost using IBM Watson translator API.
|
27 |
* Check auto translations inside Loco build-in editor to manually edit any machine translated string.
|
28 |
* This plugin uses **[IBM Watson Translator](https://www.ibm.com/in-en/cloud/watson-language-translator/)** API to auto translate plugin / theme language(po) files. Grab free api key and translate URL:- [steps to grab free api key](https://locoaddon.com/how-to-generate-ibm-watson-translator-api-key/)
|
29 |
-
* Pro version also supports Google & Microsoft Translator APIs - [Buy Pro](https://
|
30 |
|
31 |
> “If you spend too much time thinking about a thing, you'll never get it done. Stop wasting time, complete work smartly & quickly!”
|
32 |
|
@@ -54,7 +54,9 @@ This addon provides support to use IBM Watson Translator API for free users and
|
|
54 |
* ✅ **Reset Translations:** Available
|
55 |
* ✅ **HTML Translations:** Not Available Now (Yandex Translate API v1 deprecated)
|
56 |
* ✅ **Premium Support:** Quick support via email - contact@coolplugins.net (**Support time:- 24-48 hours**)
|
57 |
-
* **Buy Premium License:** [$18 - $88](https://
|
|
|
|
|
58 |
|
59 |
**Important:** Plugin only provides settings to use third party translation APIs, it do not provide any free translations characters. All free translation characters usage limit provided by API providers. Any API provider can stop providing translation API or free usage limit anytime in future, in that case plugin will not support that API provider.
|
60 |
|
@@ -66,7 +68,7 @@ https://www.youtube.com/watch?v=pjKNbkQNQDU
|
|
66 |
|
67 |
This plugin is not developed by or affiliated with the "**Loco Translate**". It is a third party addon that provides automatic machine translations to quickly translate your theme or plugin language files.
|
68 |
|
69 |
-
We(**CoolPlugins.net**) only manage [
|
70 |
|
71 |
> We provide cool solutions to remove famous plugins limitations!
|
72 |
|
@@ -84,7 +86,7 @@ All automatic translations will machine translations, powered by IBM Watson Tran
|
|
84 |
|
85 |
4. While editing any plugin or theme language file using Loco build-in editor, you will find an auto translator button at top to quickly translate all translatable strings with one-click.
|
86 |
|
87 |
-
5. If you want to use Google Translate API or Microsoft Translator API then you need to purchase [premium license key](https://
|
88 |
|
89 |
== Frequently Asked Questions ==
|
90 |
= How it works? =
|
@@ -112,6 +114,16 @@ Microsoft Translator API provides free 2,000,000 char / month for translations.
|
|
112 |
4. Free Translation Limit by API Providers
|
113 |
|
114 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
<strong>Version 1.8 | 12 JUN 2020</strong>
|
116 |
<pre>
|
117 |
Added: IBM Watson Translator API support.
|
@@ -119,7 +131,6 @@ Added: Notice! Yandex Translate API v1 deprecated.
|
|
119 |
Fixed: Bug fixes
|
120 |
Improved:endpoint updates
|
121 |
Improved: code Improvements
|
122 |
-
|
123 |
</pre>
|
124 |
<strong>Version 1.7.5 | 27 MAY 2020</strong>
|
125 |
<pre>
|
26 |
* You can automatic translate upto **1,000,000 characters** monthly free of cost using IBM Watson translator API.
|
27 |
* Check auto translations inside Loco build-in editor to manually edit any machine translated string.
|
28 |
* This plugin uses **[IBM Watson Translator](https://www.ibm.com/in-en/cloud/watson-language-translator/)** API to auto translate plugin / theme language(po) files. Grab free api key and translate URL:- [steps to grab free api key](https://locoaddon.com/how-to-generate-ibm-watson-translator-api-key/)
|
29 |
+
* Pro version also supports Google & Microsoft Translator APIs - [Buy Pro](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/)
|
30 |
|
31 |
> “If you spend too much time thinking about a thing, you'll never get it done. Stop wasting time, complete work smartly & quickly!”
|
32 |
|
54 |
* ✅ **Reset Translations:** Available
|
55 |
* ✅ **HTML Translations:** Not Available Now (Yandex Translate API v1 deprecated)
|
56 |
* ✅ **Premium Support:** Quick support via email - contact@coolplugins.net (**Support time:- 24-48 hours**)
|
57 |
+
* **Buy Premium License:** [$18 - $88](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing)
|
58 |
+
|
59 |
+
https://youtu.be/RkVwHB3hppo
|
60 |
|
61 |
**Important:** Plugin only provides settings to use third party translation APIs, it do not provide any free translations characters. All free translation characters usage limit provided by API providers. Any API provider can stop providing translation API or free usage limit anytime in future, in that case plugin will not support that API provider.
|
62 |
|
68 |
|
69 |
This plugin is not developed by or affiliated with the "**Loco Translate**". It is a third party addon that provides automatic machine translations to quickly translate your theme or plugin language files.
|
70 |
|
71 |
+
We(**CoolPlugins.net**) only manage [locoaddon.com](https://locoaddon.com) website, Loco Automatic Translate Addon(**this plugin**) and [Loco Automatic Translate Addon Premium License Key](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/).
|
72 |
|
73 |
> We provide cool solutions to remove famous plugins limitations!
|
74 |
|
86 |
|
87 |
4. While editing any plugin or theme language file using Loco build-in editor, you will find an auto translator button at top to quickly translate all translatable strings with one-click.
|
88 |
|
89 |
+
5. If you want to use Google Translate API or Microsoft Translator API then you need to purchase [premium license key](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/).
|
90 |
|
91 |
== Frequently Asked Questions ==
|
92 |
= How it works? =
|
114 |
4. Free Translation Limit by API Providers
|
115 |
|
116 |
== Changelog ==
|
117 |
+
<strong>Version 1.9 | 23 JUN 2020</strong>
|
118 |
+
<pre>
|
119 |
+
Fixed:404 Not found bug with IBM translate.
|
120 |
+
Fixed:unable to disable review notice bug
|
121 |
+
Updated:Updated settings panel and translate popup content
|
122 |
+
Removed: HTML string translation support.
|
123 |
+
Added: added some checks in strings
|
124 |
+
Improved:Improved IBM translation process
|
125 |
+
Improved: Minor JS Improvements
|
126 |
+
</pre>
|
127 |
<strong>Version 1.8 | 12 JUN 2020</strong>
|
128 |
<pre>
|
129 |
Added: IBM Watson Translator API support.
|
131 |
Fixed: Bug fixes
|
132 |
Improved:endpoint updates
|
133 |
Improved: code Improvements
|
|
|
134 |
</pre>
|
135 |
<strong>Version 1.7.5 | 27 MAY 2020</strong>
|
136 |
<pre>
|