Automatic Translate Addon For Loco Translate - Version 1.8

Version Description

Download this release

Release Info

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

Code changes from version 1.7.4 to 1.8

assets/admin/custom-styles.css CHANGED
@@ -30,3 +30,7 @@ tr.atlt_settings-field table tr td span {
30
  .wp-submenu a[href*="loco-atlt"]:hover {
31
  background: #393e45 !Important;
32
  }
 
 
 
 
30
  .wp-submenu a[href*="loco-atlt"]:hover {
31
  background: #393e45 !Important;
32
  }
33
+
34
+ tr.atlt_settings-field td input[type=text] {
35
+ width: 78%!important;
36
+ }
assets/css/atlt-admin-feedback-notice.css CHANGED
@@ -1,27 +1,34 @@
1
- .cool-feedback-notice-wrapper.notice.notice-info.is-dismissible {
2
  padding: 5px;
 
 
3
  }
4
- .cool-feedback-notice-wrapper .logo_container {
5
- width:80px;
6
- display:inline-block;
 
7
  margin-right: 10px;
8
  vertical-align: top;
9
  }
10
- .cool-feedback-notice-wrapper .logo_container img {
11
- width:100%;
12
- height:auto;
 
13
  }
14
- .cool-feedback-notice-wrapper .message_container {
 
15
  width: calc(100% - 120px);
16
  display: inline-block;
17
  margin: 0;
18
  vertical-align: top;
19
  }
20
- .cool-feedback-notice-wrapper ul li {
 
21
  float: left;
22
  margin: 0px 5px;
23
  }
24
- .cool-feedback-notice-wrapper ul li.already_rated a:before {
 
25
  color: #cc0000;
26
  content: "\f153";
27
  font: normal 16px/20px dashicons;
@@ -30,56 +37,72 @@
30
  margin-right: 4px;
31
  height: 22px;
32
  }
33
- .cool-feedback-notice-wrapper ul li.already_rated a[title="Not Interested"] {
 
34
  position: absolute;
35
  right: 5px;
36
  top: 5px;
37
  z-index: 9;
38
  }
39
- .clrfix{
40
- clear:both;
 
41
  }
42
- .atlt-progress-bar-value{
43
- width:0px;
44
- background:
45
- -webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0,0, 0, .1) 66%, transparent 66%),
46
- -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)),
47
- -webkit-linear-gradient(left, #09c, #f44);
48
- height:10px;
49
  background-size: 35px 20px, 100% 100%, 100% 100%;
50
  }
51
- .atlt-progress-bar-track{
 
52
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
53
  border: 2px solid gray;
54
  width: 100%;
55
  height: 10px;
56
  }
 
57
  #atlt-dialog .atlt-final-message {
58
  text-align: center;
59
  }
60
- #atlt-dialog .atlt-ok.button{
 
61
  margin: 0 auto;
62
  display: block;
63
  }
64
 
 
65
  /*Custom Sidebar*/
 
66
  .loco-settings-custom-sidebar {
67
  border: 4px solid #b9b9b9;
68
  max-width: 320px;
69
- width:18%;
70
  float: right;
71
  margin-right: 15px;
72
  padding: 10px;
73
  box-sizing: border-box;
74
  }
 
75
  .loco-settings-custom-sidebar h2 {
76
  background: #d6d6d6;
77
  padding: 5px;
78
  font-size: 1em;
79
  font-weight: bold;
80
  }
 
81
  .loco-settings-custom-sidebar ul li {
82
  list-style: square;
83
  padding-left: 0;
84
  margin-left: 16px;
85
  }
 
 
 
 
 
 
 
 
 
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;
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;
54
+ background: -webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, .1) 33%, rgba(0, 0, 0, .1) 66%, transparent 66%), -webkit-linear-gradient(top, rgba(255, 255, 255, .25), rgba(0, 0, 0, .25)), -webkit-linear-gradient(left, #09c, #f44);
55
+ height: 10px;
 
 
56
  background-size: 35px 20px, 100% 100%, 100% 100%;
57
  }
58
+
59
+ .atlt-progress-bar-track {
60
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
61
  border: 2px solid gray;
62
  width: 100%;
63
  height: 10px;
64
  }
65
+
66
  #atlt-dialog .atlt-final-message {
67
  text-align: center;
68
  }
69
+
70
+ #atlt-dialog .atlt-ok.button {
71
  margin: 0 auto;
72
  display: block;
73
  }
74
 
75
+
76
  /*Custom Sidebar*/
77
+
78
  .loco-settings-custom-sidebar {
79
  border: 4px solid #b9b9b9;
80
  max-width: 320px;
81
+ width: 18%;
82
  float: right;
83
  margin-right: 15px;
84
  padding: 10px;
85
  box-sizing: border-box;
86
  }
87
+
88
  .loco-settings-custom-sidebar h2 {
89
  background: #d6d6d6;
90
  padding: 5px;
91
  font-size: 1em;
92
  font-weight: bold;
93
  }
94
+
95
  .loco-settings-custom-sidebar ul li {
96
  list-style: square;
97
  padding-left: 0;
98
  margin-left: 16px;
99
  }
100
+
101
+ tr.atlt_rollbakBtn.button.primary-button th {
102
+ padding: 10px;
103
+ width: auto;
104
+ }
105
+
106
+ tr.atlt_rollbakBtn.button.primary-button td {
107
+ display: none;
108
+ }
assets/js/api-testing.js CHANGED
@@ -2,7 +2,6 @@ jQuery(document).ready(function ($) {
2
  $('.atlt_test_api').on('click', function (event) {
3
  event.preventDefault();
4
  var $this = $(this);
5
- var endpoint=info["info"]["endpoint"];
6
  $this.parent().find(".atlt-preloader").show();
7
  var ajaxURL=$this.data('ajaxurl');
8
  var source=$this.data('source');
@@ -10,8 +9,14 @@ jQuery(document).ready(function ($) {
10
  var text=$this.data('text');
11
  var apikey=$this.data('apikey');
12
  var apiprovider=$this.data('api-provider');
 
 
 
 
 
 
13
  var nonce=$this.data('nonce');
14
- var defaultString='"Hello World" Translation in French:-';
15
  var data = {
16
  'action':endpoint,
17
  'nonce':nonce,
2
  $('.atlt_test_api').on('click', function (event) {
3
  event.preventDefault();
4
  var $this = $(this);
 
5
  $this.parent().find(".atlt-preloader").show();
6
  var ajaxURL=$this.data('ajaxurl');
7
  var source=$this.data('source');
9
  var text=$this.data('text');
10
  var apikey=$this.data('apikey');
11
  var apiprovider=$this.data('api-provider');
12
+ if(apiprovider=="google" || apiprovider=="microsoft"){
13
+ var endpoint='pro_test_api_provider';
14
+ }else{
15
+ var endpoint='free_test_api_provider';
16
+
17
+ }
18
  var nonce=$this.data('nonce');
19
+ var defaultString='"Hello" Translation in French:-';
20
  var data = {
21
  'action':endpoint,
22
  'nonce':nonce,
assets/js/atlt-rollback.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+
3
+ if ($('#Btloco_rollback.button').length > 0) {
4
+ $('#Btloco_rollback.button').on('click', function() {
5
+ $('.atlt_rollbakBtn .notices').html('');
6
+ $.ajax({
7
+ url: ajaxurl,
8
+ type: 'POST',
9
+ data: {
10
+ 'action': 'atlt_rollback_request',
11
+ 'key': atlt_rollback.key
12
+ },
13
+ xhr: function() {
14
+ var xhr = new window.XMLHttpRequest();
15
+ xhr.addEventListener("progress", function(et) {
16
+ $('.atlt_rollbakBtn .notices').html($.parseHTML(et.currentTarget.responseText));
17
+ }, false);
18
+ return xhr;
19
+ },
20
+ beforeSend: function(XMLHttpRequest) {
21
+ $('.atlt_rollbakBtn .notices').text('Wait while loco translate rollback in progress...');
22
+ $('#Btloco_rollback.button').text('Rolling Back...');
23
+ },
24
+ complete: function(res) {
25
+ window.setTimeout(
26
+ function() {
27
+ window.location.reload()
28
+ }, 600
29
+ );
30
+ }
31
+ })
32
+
33
+ });
34
+ };
35
+
36
+ });
assets/js/loco-js-editor.js CHANGED
@@ -612,9 +612,9 @@ $(document).ready(function(){
612
  $('#atlt-dialog').dialog({width:440,height:500});
613
  });
614
  // main translate handler
615
-
616
  $("input[name=api_type]").on( "click",function(){
617
- if($(this).val()=="google" || $(this).val()=="microsoft"){
618
  $("#typehtmlWrapper").hide();
619
  $("#typeplain").attr("checked","checked");
620
  }else{
@@ -792,6 +792,8 @@ $(document).ready(function(){
792
  }
793
  }
794
  sourceApiKey = ATLT["api_key"]["mApiKey"];
 
 
795
  }else{
796
  sourceApiKey = ATLT["api_key"]["yApiKey"];
797
  }
@@ -853,7 +855,12 @@ $(document).ready(function(){
853
  dataObj.thisBtn=thisBtn;
854
  dataObj.apiType=apiType;
855
  dataObj.targetLang=targetLang;
856
- dataObj.endpoint=ATLT["endpoint"];
 
 
 
 
 
857
 
858
  // save data object globaly for later use
859
  window.locoEditorStats.dataObj = dataObj;
@@ -875,7 +882,7 @@ $(document).ready(function(){
875
  jQuery(document).on('atlt_run_translation',function(){
876
  let textToTranslate = window.locoEditorStats.dataObj.textToTranslateArr
877
  let totalTranslated = window.locoEditorStats.totalTranslated
878
- const apiKey = ATLT["api_key"]["yApiKey"];
879
  const nonce=ATLT["nonce"];
880
  const saveBtn=$('[data-loco="save"]');
881
  const orignalstringArr=window.locoEditorStats.dataObj.orgStrArr;
@@ -905,7 +912,6 @@ jQuery(document).on('atlt_run_translation',function(){
905
  targetLang:targetLang,
906
  textToTranslateArr:textToTranslate.slice(0,indexRequest),
907
  orginalArr:orignalstringArr,
908
- apiKey:apiKey,
909
  thisBtn:window.locoEditorStats.dataObj.thisBtn,
910
  strType:window.locoEditorStats.dataObj.strType,
911
  apiType:window.locoEditorStats.dataObj.apiType,
@@ -1147,7 +1153,7 @@ function filterRawObject(rawArray,filterType){
1147
  if((Array.isArray(plainStrings) && plainStrings.length) ||
1148
  (Array.isArray(htmlStrings)&& htmlStrings.length)
1149
  ){
1150
- 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://tech.yandex.com/translate/">Get Free API Key</a></fieldset>';
1151
  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://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing">Buy Premium License</a></span></div></fieldset>';
1152
  const apiKey=ATLT["api_key"]["yApiKey"];
1153
  const proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';
@@ -1158,14 +1164,23 @@ function filterRawObject(rawArray,filterType){
1158
  const aTodayChar=1000000;
1159
 
1160
  // not added API key
1161
- if( ATLT == '' || ATLT["api_key"] == '' || apiKey=='' ){
1162
  if( userType=='free'){
1163
  locoActions.append(inActiveBtn);
1164
  return;
1165
  }else{
1166
  locoActions.append(proActiveBtn);
1167
  }
1168
- }else if( allowed=="no" && userType=='free'){
 
 
 
 
 
 
 
 
 
1169
  // free not allowed
1170
  locoActions.append(disabledBtn);
1171
  return;
@@ -1292,14 +1307,17 @@ function createSettingsPopup(){
1292
  let preloaderImg=extradata['preloader_path'];
1293
  const userInfo=ATLT["info"].type;
1294
  const yAC=ATLT["info"].yAvailableChars;
 
1295
  const licenseKey=ATLT["info"]["licenseKey"];
1296
  const proInstalled=ATLT["info"]["proInstalled"];
1297
  let yfieldStatus="";
 
1298
  let gfieldStatus="";
1299
  let mfieldStatus="";
1300
  let hfieldStatus="";
1301
  let htmlSupported="";
1302
  let contCls="";
 
1303
  let proLbl="";
1304
  let gContCls='';
1305
  let gHtml='';
@@ -1307,7 +1325,9 @@ function createSettingsPopup(){
1307
  let mHtml='';
1308
  let submitBtn='';
1309
  let yHtml='';
1310
- let yChecked='checked="true"';
 
 
1311
  if(userInfo=="free"){
1312
  let gAC=0;
1313
  gfieldStatus="disabled";
@@ -1360,21 +1380,34 @@ function createSettingsPopup(){
1360
  mContCls='m-disabled';
1361
  mHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Microsoft Translator API key)</span>';
1362
  }
1363
-
1364
-
1365
- if(ATLT["api_key"]["yApiKey"]!="")
1366
- {
1367
- if(yAC!==undefined){
1368
- yHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(yAC)+' Free Char. Available Today)</span>';
1369
- }
1370
- }else{
1371
- yfieldStatus="disabled";
1372
- yContCls='g-disabled';
1373
- yChecked='';
1374
- yHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Yandex Translate API key)</span>';
1375
- }
1376
  }
1377
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1378
 
1379
  if( ATLT["api_key"]["yApiKey"]!="" || ATLT["api_key"]["gApiKey"]!="" || ATLT["api_key"]["mApiKey"]!="" )
1380
  {
@@ -1386,11 +1419,18 @@ function createSettingsPopup(){
1386
  let settingsHTML=`<div class="atlt-settings">
1387
  <form id="atlt-settings-form" method="post" action="#">
1388
  <strong class="atlt-heading">Select Translation API</strong>
 
 
 
 
 
 
1389
  <div class="inputGroup">
1390
  <input class="inputEle" type="radio" id="yandex_api"
1391
  ${yChecked} ${yfieldStatus} name="api_type" value="yandex">
1392
  <label for="yandex_api">Yandex Translate ${yHtml}</label>
1393
  </div>
 
1394
  <div class="inputGroup ${gContCls}">
1395
  <input class="inputEle" type="radio" id="google_api"
1396
  name="api_type" value="google" ${gfieldStatus}>
@@ -1407,11 +1447,11 @@ function createSettingsPopup(){
1407
  <strong class="atlt-heading">Select Content Type</strong>
1408
  <div class="inputGroup">
1409
  <input class="inputEle" type="radio" id="typeplain" checked="true" name="translationtype" value="plain">
1410
- <label for="typeplain">Translate Plain Text Strings</label>
1411
  </div>
1412
  <div id="typehtmlWrapper" class="inputGroup ${contCls}">
1413
  <input class="inputEle" type="radio" id="typehtml" name="translationtype" value="html" ${hfieldStatus}>
1414
- <label for="typehtml">Translate HTML Strings (Beta) ${proLbl}
1415
  </label>
1416
  </br>
1417
  <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>
612
  $('#atlt-dialog').dialog({width:440,height:500});
613
  });
614
  // main translate handler
615
+ $("#typehtmlWrapper").hide();
616
  $("input[name=api_type]").on( "click",function(){
617
+ if($(this).val()=="google" || $(this).val()=="microsoft" || $(this).val()=="ibm"){
618
  $("#typehtmlWrapper").hide();
619
  $("#typeplain").attr("checked","checked");
620
  }else{
792
  }
793
  }
794
  sourceApiKey = ATLT["api_key"]["mApiKey"];
795
+ }else if(apiType=="ibm"){
796
+ sourceApiKey = ATLT["api_key"]["ibmApiKey"];
797
  }else{
798
  sourceApiKey = ATLT["api_key"]["yApiKey"];
799
  }
855
  dataObj.thisBtn=thisBtn;
856
  dataObj.apiType=apiType;
857
  dataObj.targetLang=targetLang;
858
+ if(apiType=="google" || apiType=="microsoft"){
859
+ dataObj.endpoint='pro_autotranslate_handler';
860
+ }else{
861
+ dataObj.endpoint='free_autotranslate_handler';
862
+ }
863
+
864
 
865
  // save data object globaly for later use
866
  window.locoEditorStats.dataObj = dataObj;
882
  jQuery(document).on('atlt_run_translation',function(){
883
  let textToTranslate = window.locoEditorStats.dataObj.textToTranslateArr
884
  let totalTranslated = window.locoEditorStats.totalTranslated
885
+
886
  const nonce=ATLT["nonce"];
887
  const saveBtn=$('[data-loco="save"]');
888
  const orignalstringArr=window.locoEditorStats.dataObj.orgStrArr;
912
  targetLang:targetLang,
913
  textToTranslateArr:textToTranslate.slice(0,indexRequest),
914
  orginalArr:orignalstringArr,
 
915
  thisBtn:window.locoEditorStats.dataObj.thisBtn,
916
  strType:window.locoEditorStats.dataObj.strType,
917
  apiType:window.locoEditorStats.dataObj.apiType,
1153
  if((Array.isArray(plainStrings) && plainStrings.length) ||
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://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing">Buy Premium License</a></span></div></fieldset>';
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>';
1164
  const aTodayChar=1000000;
1165
 
1166
  // not added API key
1167
+ if( ATLT == undefined || ATLT["api_key"] =='' ){
1168
  if( userType=='free'){
1169
  locoActions.append(inActiveBtn);
1170
  return;
1171
  }else{
1172
  locoActions.append(proActiveBtn);
1173
  }
1174
+ }else if(
1175
+ ATLT["api_key"]["yApiKey"]=="" && ATLT["api_key"]["ibmApiKey"]==""){
1176
+ if( userType=='free'){
1177
+ locoActions.append(inActiveBtn);
1178
+ return;
1179
+ }else{
1180
+ locoActions.append(proActiveBtn);
1181
+ }
1182
+ }
1183
+ else if( allowed=="no" && userType=='free'){
1184
  // free not allowed
1185
  locoActions.append(disabledBtn);
1186
  return;
1307
  let preloaderImg=extradata['preloader_path'];
1308
  const userInfo=ATLT["info"].type;
1309
  const yAC=ATLT["info"].yAvailableChars;
1310
+ const iAC=ATLT["info"].iAvailableChars;
1311
  const licenseKey=ATLT["info"]["licenseKey"];
1312
  const proInstalled=ATLT["info"]["proInstalled"];
1313
  let yfieldStatus="";
1314
+ let ifieldStatus="";
1315
  let gfieldStatus="";
1316
  let mfieldStatus="";
1317
  let hfieldStatus="";
1318
  let htmlSupported="";
1319
  let contCls="";
1320
+ let icontCls="";
1321
  let proLbl="";
1322
  let gContCls='';
1323
  let gHtml='';
1325
  let mHtml='';
1326
  let submitBtn='';
1327
  let yHtml='';
1328
+ let iHtml='';
1329
+ let yChecked='"';
1330
+ let iChecked='checked="true"';
1331
  if(userInfo=="free"){
1332
  let gAC=0;
1333
  gfieldStatus="disabled";
1380
  mContCls='m-disabled';
1381
  mHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Microsoft Translator API key)</span>';
1382
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
1383
  }
1384
  }
1385
+ if(ATLT["api_key"]["yApiKey"]!="")
1386
+ {
1387
+ if(yAC!==undefined){
1388
+ yHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(yAC)+' Free Char. Available Monthly)</span>';
1389
+ }
1390
+ }else{
1391
+ yfieldStatus="disabled";
1392
+ yContCls='g-disabled';
1393
+ yChecked='';
1394
+ yHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Yandex Translate API v1 key)</span>';
1395
+ }
1396
+ if(ATLT["api_key"]["ibmApiKey"]=="" || ATLT["info"]["ibm_url"]==""){
1397
+ ifieldStatus="disabled";
1398
+ iContCls='g-disabled';
1399
+ iChecked='';
1400
+ iHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter IBM Translate API key/URL)</span>';
1401
+ }else{
1402
+ if(iAC!==undefined){
1403
+ iHtml='<span class="available-chars" style="font-weight:bold;font-size:0.9em;"> ('+atltFormatNumber(iAC)+' Free Char. Available Monthly)</span>';
1404
+ }
1405
+ }
1406
+ if(userInfo=="free"){
1407
+ plainStringLbl='Translate Plain Text Strings(No HTML/Special character supported)';
1408
+ }else{
1409
+ plainStringLbl='Translate Plain Text Strings';
1410
+ }
1411
 
1412
  if( ATLT["api_key"]["yApiKey"]!="" || ATLT["api_key"]["gApiKey"]!="" || ATLT["api_key"]["mApiKey"]!="" )
1413
  {
1419
  let settingsHTML=`<div class="atlt-settings">
1420
  <form id="atlt-settings-form" method="post" action="#">
1421
  <strong class="atlt-heading">Select Translation API</strong>
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">
1431
  <label for="yandex_api">Yandex Translate ${yHtml}</label>
1432
  </div>
1433
+
1434
  <div class="inputGroup ${gContCls}">
1435
  <input class="inputEle" type="radio" id="google_api"
1436
  name="api_type" value="google" ${gfieldStatus}>
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>
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&&registerSaveButton,sync:editable&&registerSyncButton,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&&regex.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://tech.yandex.com/translate/">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(""==ATLT||""==ATLT.api_key||""==apiKey){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,licenseKey=ATLT.info.licenseKey,proInstalled=ATLT.info.proInstalled;let yfieldStatus="",gfieldStatus="",mfieldStatus="",hfieldStatus="",htmlSupported="",contCls="",proLbl="",gContCls="",gHtml="",mContCls="",mHtml="",submitBtn="",yHtml="",yChecked='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 Today)</span>"):(yfieldStatus="disabled",yContCls="g-disabled",yChecked="",yHtml='<span class="error" style="color:red;font-size:0.85em;">(Please enter Yandex Translate API key)</span>')}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="yandex_api" \n ${yChecked} ${yfieldStatus} name="api_type" value="yandex">\n <label for="yandex_api">Yandex Translate ${yHtml}</label>\n </div>\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">Translate Plain Text Strings</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 (Beta) ${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&&registerAddButton,buttons.del=editable&&registerDelButton):buttons.fuzzy=registerFuzzyButton,$("#loco-toolbar").find("button").each((function(i,el){var id=el.getAttribute("data-loco"),register=buttons[id];register&&register(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})})),$("input[name=api_type]").on("click",(function(){"google"==$(this).val()||"microsoft"==$(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=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=ATLT.endpoint,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 apiKey=ATLT.api_key.yApiKey,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,apiKey:apiKey,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&&registerSaveButton,sync:editable&&registerSyncButton,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&&regex.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&&registerAddButton,buttons.del=editable&&registerDelButton):buttons.fuzzy=registerFuzzyButton,$("#loco-toolbar").find("button").each((function(i,el){var id=el.getAttribute("data-loco"),register=buttons[id];register&&register(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);
automatic-translator-addon-for-loco-translate.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
- Description:Auto language translator add-on for Loco Translate plugin to translate plugins and themes translation files into any language via fully automatic machine translations via yandex Translate API.
5
- Version:1.7.4
6
  License:GPL2
7
  Text Domain:loco-translate-addon
8
  Domain Path:languages
@@ -11,9 +11,10 @@ Author URI:https://coolplugins.net/
11
  */
12
  namespace LocoAutoTranslateAddon;
13
  use LocoAutoTranslateAddon\Helpers\Helpers;
 
14
  /**
15
  * @package Loco Automatic Translate Addon
16
- * @version 1.7.4
17
  */
18
  if (!defined('ABSPATH')) {
19
  die('WordPress Environment Not Found!');
@@ -22,7 +23,7 @@ if (!defined('ABSPATH')) {
22
  define('ATLT_FILE', __FILE__);
23
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
24
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
25
- define('ATLT_VERSION', '1.7.3');
26
 
27
  class LocoAutoTranslate
28
  {
@@ -31,6 +32,9 @@ class LocoAutoTranslate
31
  register_activation_hook( ATLT_FILE, array( $this, 'atlt_activate' ) );
32
  register_deactivation_hook( ATLT_FILE, array( $this, 'atlt_deactivate' ) );
33
  if(is_admin()){
 
 
 
34
  add_action('plugins_loaded', array($this, 'atlt_check_required_loco_plugin'));
35
  /*** Template Setting Page Link inside Plugins List */
36
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this,'atlt_settings_page_link'));
@@ -45,12 +49,35 @@ class LocoAutoTranslate
45
  }
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  public function use_loco_autotranslate_notice(){
49
  //get the current screen
50
  $screen = get_current_screen();
 
 
 
 
51
  //return if not plugin settings page
52
  //To get the exact your screen ID just do ver_dump($screen)
53
- if (in_array($screen->id, array('loco-translate_page_loco-atlt','loco-translate_page_loco-atlt-register')))
 
 
 
 
 
 
 
54
  {
55
  $loco_vesion=loco_plugin_version();
56
  if (version_compare( $loco_vesion, '2.4', '>=')) {
@@ -58,10 +85,10 @@ class LocoAutoTranslate
58
  $url= admin_url( 'admin.php?page=loco-config&action=apis');
59
  echo '<div class="error"><p style="font-size:16px;">' .
60
  sprintf(__(
61
- '<strong style="color:red">Notice from <a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/" target="_blank">Loco Addon</a> Owner:</strong> All premium features of <a href="https://wordpress.org/plugins/automatic-translator-addon-for-loco-translate/" target="_blank"><strong>Automatic Translate Addon For Loco Translate</strong></a> has been integrated inside new version of <a href="https://wordpress.org/plugins/loco-translate/" target="_blank"><strong>Loco Translate</strong></a> (2.4.0+) free official plugin. So add translate API keys inside its <a href="%s"><strong>Settings</strong></a> and enjoy automatic translations using Google, Microsoft or Yandex APIs. You can now deactivate <strong>Automatic Translate Addon For Loco Translate</strong>',
62
  'loco-translate-addon'),
63
  esc_url($url)
64
- ) . '.</p></div>';
65
  }
66
  }
67
  }
@@ -100,6 +127,8 @@ class LocoAutoTranslate
100
  include_once ATLT_PATH . 'includes/Feedback/class.feedback-form.php';
101
  new FeedbackForm\FeedbackForm();
102
  include_once ATLT_PATH . 'includes/Register/LocoAutomaticTranslateAddonPro.php';
 
 
103
  }
104
 
105
  }
@@ -121,6 +150,7 @@ class LocoAutoTranslate
121
  echo $this->errorResponse('You have consumed API daily limit');
122
  die();
123
  }
 
124
  // get request vars
125
  if (empty($_REQUEST['data'])) {
126
  echo $this->errorResponse('No String Found');
@@ -138,9 +168,11 @@ class LocoAutoTranslate
138
  $request_chars = $_REQUEST['requestChars'];
139
  $totalChars = $_REQUEST['totalCharacters'];
140
  $requestType=$_REQUEST['strType'];
141
- $apiType=$_REQUEST['apiType'];
142
  $stringArr= json_decode(stripslashes($requestData),true);
143
- // grab API keys
 
 
144
  $api_key = Helpers::getAPIkey("yandex");
145
  if(empty($api_key)|| $api_key==""){
146
  echo $this->errorResponse('You have not Entered yandex API Key');
@@ -167,7 +199,48 @@ class LocoAutoTranslate
167
  $responseArr['error']=$response;
168
  $responseArr['code']=500;
169
  }
170
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  die(json_encode($responseArr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
172
  }
173
  }
@@ -231,8 +304,11 @@ class LocoAutoTranslate
231
  public function atlt_plugin_required_admin_notice()
232
  {
233
  if (current_user_can('activate_plugins')) {
 
 
 
234
  echo '<div class="error"><p>' .
235
- sprintf(__('In order to use <strong>%s</strong> plugin, please install and activate the latest version of <a href="%s" class="thickbox" title="%s">%s</a>',
236
  'loco-translate-addon'),
237
  $plugin_info['Name'], esc_url($url),
238
  esc_attr($title), esc_attr($title)) . '.</p></div>';
@@ -255,6 +331,9 @@ class LocoAutoTranslate
255
  $sourceLang=$_REQUEST['source'];
256
  $apikey=$_REQUEST['apikey'];
257
  $apiType=$_REQUEST['apiprovider'];
 
 
 
258
  $strArr[]=$text;
259
  $requestType="plain";
260
  $response=$this->yandex_api_call(
@@ -272,6 +351,33 @@ class LocoAutoTranslate
272
  $responseArr['code']=500;
273
  $responseArr['error']= $response;
274
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  die(json_encode($responseArr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
276
  }
277
  }
@@ -297,19 +403,36 @@ class LocoAutoTranslate
297
  */
298
  public function saveStringsCount($request_chars,$totalChars,$apiType)
299
  {
300
- $today_translated = Helpers::ytodayTranslated( $request_chars);
301
- $monthly_translated = Helpers::ymonthlyTranslated( $request_chars);
302
- /** Calculate the total time save on translation */
303
- $session_time_saved = Helpers::atlt_time_saved_on_translation( $totalChars);
304
- $total_time_saved = Helpers::atlt_time_saved_on_translation($totalChars);
305
- // create response array
306
- $stats=array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  'todays_translation'=>$today_translated,
308
  'total_translation'=>$monthly_translated,
309
  'time_saved'=> $session_time_saved,
310
  'total_time_saved'=>$total_time_saved,
311
  'totalChars'=>$totalChars
312
  );
 
313
  return $stats;
314
  }
315
 
@@ -357,28 +480,45 @@ class LocoAutoTranslate
357
  //sweet alert for settings panel
358
  wp_register_script( 'settings-sweet-alert', ATLT_URL.'assets/sweetalert/sweetalert.min.js',array('jquery'),false, true);
359
  wp_register_script( 'test-api', ATLT_URL.'assets/js/api-testing.js', array('jquery','settings-sweet-alert'));
360
- wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.min.js', array('loco-js-min-admin'),false, true);
361
- wp_register_script( 'loco-js-test', ATLT_URL.'assets/js/loco-autotranslate-handler.js', array('loco-js-min-admin'),false, true);
 
362
 
363
  if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
364
  {
365
  $data=array();
366
  wp_enqueue_script('sweet-alert');
367
- // wp_enqueue_script('loco-js-test');
368
  wp_enqueue_script('loco-js-editor');
369
 
370
  $status=Helpers::atltVerification();
371
  $data['api_key']['yApiKey']=Helpers::getAPIkey("yandex");
372
  $data['info']['yAvailableChars']=Helpers::getAvailableChars("yandex");
 
 
 
 
373
  $data['nonce']= wp_create_nonce('atlt_nonce');
374
  $data['endpoint']='free_autotranslate_handler';
375
  // @since version 1.7.1
376
  $settings=get_option('atlt_register');
 
 
 
 
 
 
377
  $index_per_request=isset($settings['atlt_index-per-request'])?$settings['atlt_index-per-request']:50;
378
  $data['api_key']['atlt_index-per-request']=$index_per_request;
379
 
380
  if($status['type']=="free"){
381
- $data['info']=Helpers::atltVerification();
 
 
 
 
 
 
382
  }else{
383
  $data['api_key']['gApiKey']=Helpers::getAPIkey("google");
384
  $data['api_key']['mApiKey']=Helpers::getAPIkey("microsoft");
@@ -406,18 +546,8 @@ class LocoAutoTranslate
406
  {
407
  wp_enqueue_script('settings-sweet-alert');
408
  wp_enqueue_script('test-api');
409
- $status=Helpers::atltVerification();
410
- if($status['type']=="free"){
411
- $testdata['info']['endpoint']='free_test_api_provider';
412
- }else{
413
- $key=Helpers::getLicenseKey();
414
- if(Helpers::validKey( $key) && Helpers::proInstalled()==true){
415
- $testdata['info']['endpoint']='pro_test_api_provider';
416
- }else{
417
- $testdata['info']['endpoint']='free_test_api_provider';
418
- }
419
- }
420
- wp_localize_script('test-api', 'info', $testdata);
421
  }
422
 
423
  }
1
  <?php
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.8
6
  License:GPL2
7
  Text Domain:loco-translate-addon
8
  Domain Path:languages
11
  */
12
  namespace LocoAutoTranslateAddon;
13
  use LocoAutoTranslateAddon\Helpers\Helpers;
14
+ use LocoAutoTranslateAddon\Helpers\Atlt_rollback;
15
  /**
16
  * @package Loco Automatic Translate Addon
17
+ * @version 1.8
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.8');
27
 
28
  class LocoAutoTranslate
29
  {
32
  register_activation_hook( ATLT_FILE, array( $this, 'atlt_activate' ) );
33
  register_deactivation_hook( ATLT_FILE, array( $this, 'atlt_deactivate' ) );
34
  if(is_admin()){
35
+
36
+ // Only loged in user can perform this AJAX request
37
+ add_action('wp_ajax_atlt_rollback_request', array($this, 'atlt_rollback_request'));
38
  add_action('plugins_loaded', array($this, 'atlt_check_required_loco_plugin'));
39
  /*** Template Setting Page Link inside Plugins List */
40
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this,'atlt_settings_page_link'));
49
  }
50
  }
51
 
52
+ /**
53
+ * This function hooked with AJAX to rollback loco translate plugin
54
+ */
55
+ public function atlt_rollback_request(){
56
+
57
+ require ATLT_PATH . 'includes/Helpers/Atlt_rollback.php';
58
+ $request = new Atlt_rollback();
59
+ $response = $request->rollback();
60
+ die(json_encode($response) );
61
+
62
+ }
63
+
64
  public function use_loco_autotranslate_notice(){
65
  //get the current screen
66
  $screen = get_current_screen();
67
+ $show_in_screens = array('loco-translate_page_loco-atlt',
68
+ 'loco-translate_page_loco-atlt-register',
69
+ 'loco-translate_page_loco-plugin',
70
+ 'loco-translate_page_loco-theme');
71
  //return if not plugin settings page
72
  //To get the exact your screen ID just do ver_dump($screen)
73
+
74
+ $rollback_notice = '';
75
+ if( $screen->id != 'loco-translate_page_loco-atlt' ){
76
+ $link = admin_url( 'admin.php?page=loco-atlt' );
77
+ $rollback_notice = __(' You can rollback through <a href="'.$link.'">settings</a> page.', 'loco-translate-addon');
78
+ }
79
+
80
+ if (in_array($screen->id, $show_in_screens ) )
81
  {
82
  $loco_vesion=loco_plugin_version();
83
  if (version_compare( $loco_vesion, '2.4', '>=')) {
85
  $url= admin_url( 'admin.php?page=loco-config&action=apis');
86
  echo '<div class="error"><p style="font-size:16px;">' .
87
  sprintf(__(
88
+ '<strong style="color:red">Notice from <a href="https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/" target="_blank">Loco Addon</a> Owner:</strong> <strong>Automatic Translate Addon For Loco Translate</strong> is only compatible with Loco Translate official plugin version <strong>2.3.3</strong> or lower. Currently you are using Loco Translate official plugin version 2.4.0 or higher. Please rollback to use all features of automatic translate addon.'.$rollback_notice,
89
  'loco-translate-addon'),
90
  esc_url($url)
91
+ ) . '</p></div>';
92
  }
93
  }
94
  }
127
  include_once ATLT_PATH . 'includes/Feedback/class.feedback-form.php';
128
  new FeedbackForm\FeedbackForm();
129
  include_once ATLT_PATH . 'includes/Register/LocoAutomaticTranslateAddonPro.php';
130
+
131
+ include_once ATLT_PATH .'includes/ibm-translator/class.ibm-translator.php';
132
  }
133
 
134
  }
150
  echo $this->errorResponse('You have consumed API daily limit');
151
  die();
152
  }
153
+
154
  // get request vars
155
  if (empty($_REQUEST['data'])) {
156
  echo $this->errorResponse('No String Found');
168
  $request_chars = $_REQUEST['requestChars'];
169
  $totalChars = $_REQUEST['totalCharacters'];
170
  $requestType=$_REQUEST['strType'];
171
+ $apiType=$_REQUEST['apiType'];
172
  $stringArr= json_decode(stripslashes($requestData),true);
173
+
174
+ if($apiType=="yandex"){
175
+ // grab API keys
176
  $api_key = Helpers::getAPIkey("yandex");
177
  if(empty($api_key)|| $api_key==""){
178
  echo $this->errorResponse('You have not Entered yandex API Key');
199
  $responseArr['error']=$response;
200
  $responseArr['code']=500;
201
  }
202
+ }
203
+ }else{
204
+ // grab API keys
205
+ $api_key = Helpers::getAPIkey("ibm");
206
+ if(empty($api_key)|| $api_key==""){
207
+ echo $this->errorResponse('You have not Entered IBM API Key');
208
+ die();
209
+ }
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');
217
+ die();
218
+ }
219
+ if(is_array( $stringArr)&& !empty($stringArr))
220
+ {
221
+ $args['key']= $apiKey;
222
+ $args['from']=$sourceLang;
223
+ $args['to']=$targetLang;
224
+ $args['text']=$stringArr;
225
+ $ibm_obj= new ibmTranslator();
226
+ $response=$ibm_obj->translate($args);
227
+ if(is_array($response) && $response['code']==200)
228
+ {
229
+ // grab translation count data
230
+ $responseArr['code']=200;
231
+ $responseArr['translatedString']= $response['translation'];
232
+ $responseArr['stats']= $this->saveStringsCount($request_chars,$totalChars,$apiType);
233
+ }else if(isset($response['code'])){
234
+ $responseArr['code']=$response['code'];
235
+ $responseArr['error']=$response['error'];
236
+ }else{
237
+ $responseArr['error']=$response;
238
+ $responseArr['code']=500;
239
+ }
240
+
241
+ }
242
+ }
243
+
244
  die(json_encode($responseArr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
245
  }
246
  }
304
  public function atlt_plugin_required_admin_notice()
305
  {
306
  if (current_user_can('activate_plugins')) {
307
+ $url = 'plugin-install.php?tab=plugin-information&plugin=loco-translate&TB_iframe=true';
308
+ $title = "Loco Translate";
309
+ $plugin_info = get_plugin_data(__FILE__, true, true);
310
  echo '<div class="error"><p>' .
311
+ sprintf(__('In order to use <strong>%s</strong> plugin, please install and activate the version 2.3.3 of <a href="%s" class="thickbox" title="%s">%s</a>',
312
  'loco-translate-addon'),
313
  $plugin_info['Name'], esc_url($url),
314
  esc_attr($title), esc_attr($title)) . '.</p></div>';
331
  $sourceLang=$_REQUEST['source'];
332
  $apikey=$_REQUEST['apikey'];
333
  $apiType=$_REQUEST['apiprovider'];
334
+
335
+ if( $apiType=="yandex"){
336
+
337
  $strArr[]=$text;
338
  $requestType="plain";
339
  $response=$this->yandex_api_call(
351
  $responseArr['code']=500;
352
  $responseArr['error']= $response;
353
  }
354
+ }else{
355
+ $strArr[]=$text;
356
+ $args['from']=$sourceLang;
357
+ $args['to']=$targetLang;
358
+ $args['text']=$strArr;
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();
366
+ $response=$ibm_obj->translate($args);
367
+ if(is_array($response) && $response['code']==200)
368
+ {
369
+ // grab translation count data
370
+ $responseArr['code']=200;
371
+ $responseArr['translatedString']= $response['translation'];
372
+ }else if(isset($response['code']) && isset($response['error'])){
373
+ $responseArr['code']= $response['code'];
374
+ $responseArr['error']= $response['error'];
375
+ }else{
376
+ $responseArr['code']=500;
377
+ $responseArr['error']= $response;
378
+ }
379
+
380
+ }
381
  die(json_encode($responseArr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
382
  }
383
  }
403
  */
404
  public function saveStringsCount($request_chars,$totalChars,$apiType)
405
  {
406
+
407
+ if($apiType=="yandex"){
408
+ $today_translated = Helpers::ytodayTranslated( $request_chars);
409
+ $monthly_translated = Helpers::ymonthlyTranslated( $request_chars);
410
+ /** Calculate the total time save on translation */
411
+ $session_time_saved = Helpers::atlt_time_saved_on_translation( $totalChars);
412
+ $total_time_saved = Helpers::atlt_time_saved_on_translation($totalChars);
413
+ // create response array
414
+ $stats=array(
415
+ 'todays_translation'=>$today_translated,
416
+ 'total_translation'=>$monthly_translated,
417
+ 'time_saved'=> $session_time_saved,
418
+ 'total_time_saved'=>$total_time_saved,
419
+ 'totalChars'=>$totalChars
420
+ );
421
+ }else{
422
+ $today_translated = Helpers::iTodayTranslated( $request_chars);
423
+ $monthly_translated = Helpers::iMonthlyTranslated( $request_chars);
424
+ /** Calculate the total time save on translation */
425
+ $session_time_saved = Helpers::atlt_time_saved_on_translation( $totalChars);
426
+ $total_time_saved = Helpers::atlt_time_saved_on_translation($totalChars);
427
+ // create response array
428
+ $stats=array(
429
  'todays_translation'=>$today_translated,
430
  'total_translation'=>$monthly_translated,
431
  'time_saved'=> $session_time_saved,
432
  'total_time_saved'=>$total_time_saved,
433
  'totalChars'=>$totalChars
434
  );
435
+ }
436
  return $stats;
437
  }
438
 
480
  //sweet alert for settings panel
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
+ wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.min.js', array('loco-js-min-admin'),ATLT_VERSION, true);
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");
497
+
498
+ $data['api_key']['ibmApiKey']=Helpers::getAPIkey("ibm");
499
+ $data['info']['iAvailableChars']=Helpers::getAvailableChars("ibm");
500
+
501
  $data['nonce']= wp_create_nonce('atlt_nonce');
502
  $data['endpoint']='free_autotranslate_handler';
503
  // @since version 1.7.1
504
  $settings=get_option('atlt_register');
505
+
506
+ if(isset($settings['atlt_ibm-translate-url'])){
507
+ $data['info']['ibm_url']=$settings['atlt_ibm-translate-url'];
508
+ }else{
509
+ $data['info']['ibm_url']=false;
510
+ }
511
  $index_per_request=isset($settings['atlt_index-per-request'])?$settings['atlt_index-per-request']:50;
512
  $data['api_key']['atlt_index-per-request']=$index_per_request;
513
 
514
  if($status['type']=="free"){
515
+ $info=Helpers::atltVerification();
516
+ $data['info']['type']= $info['type'];
517
+ $data['info']['total']= $info['total'];
518
+ if(isset($info['today'])){
519
+ $data['info']['today']= $info['today'];
520
+ }
521
+ $data['info']['allowed']= $info['allowed'];
522
  }else{
523
  $data['api_key']['gApiKey']=Helpers::getAPIkey("google");
524
  $data['api_key']['mApiKey']=Helpers::getAPIkey("microsoft");
546
  {
547
  wp_enqueue_script('settings-sweet-alert');
548
  wp_enqueue_script('test-api');
549
+ wp_enqueue_script('atlt-rollback');
550
+ wp_localize_script( 'atlt-rollback', 'atlt_rollback',array('key'=> wp_create_nonce('atlt_nounce_rollback_loco')) );
 
 
 
 
 
 
 
 
 
 
551
  }
552
 
553
  }
includes/Core/class.settings-api.php CHANGED
@@ -556,10 +556,10 @@ class Settings_API {
556
  <p>We hope our plugin helped you a little by automating your plugins and themes strings translation process. If you like it, please share some feedback for our team below.</p>
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, Yandex 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://locotranslate.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://locotranslate.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://tech.yandex.com/translate/" target="_blank" class="button button-secondary">Generate Yandex Translate API Key</a></p>
563
  <?php
564
  }
565
  else if($is_pro_active && $license_key== ''){
@@ -586,10 +586,9 @@ class Settings_API {
586
  <ul>
587
  <li>Google Translate API.</li>
588
  <li>Microsoft Translate API.</li>
589
- <li>Google & Microsoft automated translations are 70% better than Yandex.</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>HTML translations support via Yandex API.</li>
593
  <li>Regular updates with new features</li>
594
  <li>Premium support via email.</li>
595
  </ul>
556
  <p>We hope our plugin helped you a little by automating your plugins and themes strings translation process. If you like it, please share some feedback for our team below.</p>
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://locotranslate.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://locotranslate.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
  }
565
  else if($is_pro_active && $license_key== ''){
586
  <ul>
587
  <li>Google Translate API.</li>
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>
includes/Core/class.settings-panel.php CHANGED
@@ -73,10 +73,40 @@ if( !class_exists( 'Settings_Panel' ) ){
73
  <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
74
  </tr>
75
  </table>
76
- *Check your correct translation limit usage inside API dashboard if you are using same API key on multiple sites.';
 
77
  return $info_tbl;
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  public function create_microsoft_stats_tbl(){
82
  $month = get_option('m_translation_month');
@@ -101,7 +131,8 @@ if( !class_exists( 'Settings_Panel' ) ){
101
  <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
102
  </tr>
103
  </table>
104
- *Check your correct translation limit usage inside API dashboard if you are using same API key on multiple sites.';
 
105
  return $info_tbl;
106
  }
107
 
@@ -110,21 +141,36 @@ if( !class_exists( 'Settings_Panel' ) ){
110
  $desc='';
111
  $sourceLang='en';
112
  $targetLang='fr';
113
- $rawString='Hello World';
 
114
  $ajax_url= admin_url( 'admin-ajax.php' );
115
  $nonce= wp_create_nonce('atlt_nonce');
116
- if($name=="microsoft"){
 
117
  $apiKey= Helpers::getAPIkey("microsoft");
118
  $lbl='Microsoft Translation';
119
  $desc='<a target="_blank" href="https://locotranslate.com/how-to-generate-microsoft-translator-api-key/">Check Microsoft Translator API key generation guide.</a>';
120
- }else if($name=="google"){
121
- $apiKey= Helpers::getAPIkey("google");
122
- $lbl='Google Translation';
123
- $desc= '<a target="_blank" href="https://locotranslate.com/howto-generate-google-translate-api-key/">Check Google Translator API key generation guide.</a>';
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }else{
125
  $apiKey= Helpers::getAPIkey("yandex");
126
  $lbl='Yandex Translation';
127
- $desc='<a target="_blank" href="https://tech.yandex.com/translate/">Click here to get Yandex Translator free API key.</a>';
128
  }
129
  if($apiKey){
130
  $output .='<div><a class="atlt_test_api button button-primary button-small"
@@ -139,9 +185,10 @@ if( !class_exists( 'Settings_Panel' ) ){
139
  }else{
140
  $output.=$desc;
141
  }
142
-
143
  return $output;
144
- }
 
145
  /*
146
  |--------------------------------------------------------------------
147
  | return all settings fields to be initialized in settings page
@@ -205,24 +252,34 @@ if( !class_exists( 'Settings_Panel' ) ){
205
  <td>'.number_format($today_aval).'<br/><span>(Available Today)</span></td>
206
  <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
207
  </tr>
208
- </table>';
 
 
209
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
  $pro_per_day=1000000;
212
  $pro_per_mon=10000000;
213
  $pro_info='<table>
214
  <tr>
215
- <th>Yandex Translate API<br/>(Free Char Limit)</th>
216
- <td style="min-width:200px;">'.number_format($pro_per_day).' / Day<br/>'.number_format($pro_per_mon).' / Month</td>
217
- <td rowspan="3" style="max-width:200px;"><p>Free characters translation limit only provided by Translate API providers, e.g. - Google, Microsoft, Yandex etc.<br/>Plugin do not provide any free characters limit for automatic translations.</p></td>
218
  </tr>
219
  <tr>
220
- <th>Google Translate API<br/>(Free Char Limit)</th>
221
- <td style="min-width:200px;">'.number_format(500000).' / Month</td>
222
- </tr>
223
- <tr>
224
- <th>Microsoft Translator API<br/>(Free Char Limit)</th>
225
- <td style="min-width:200px;">'.number_format(2000000).' / Month</td>
226
  </tr>
227
  </table>';
228
 
@@ -230,12 +287,32 @@ if( !class_exists( 'Settings_Panel' ) ){
230
  'name' => $this->PREFIX.'api-key',
231
  'id' => $this->PREFIX.'api-key',
232
  'class' => $this->PREFIX.'settings-field',
233
- 'label' => 'Enter Yandex Translate<br/>API Key:',
234
  'desc' =>$this->APIIntegrationTesting("yandex"),
235
  'type' => 'text',
236
  'placeholder'=>__('Yandex API Key','cmb2'),
237
  'default' => ''
238
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  if(Helpers::userType()=="pro" && Helpers::proInstalled()==false) {
240
  $key=Helpers::getLicenseKey();
241
  $url =esc_url( add_query_arg( 'license-key',$key , 'https://locotranslate.com/data/download-plugin.php' ) );
@@ -330,7 +407,6 @@ if( !class_exists( 'Settings_Panel' ) ){
330
  'placeholder'=>__('50','cmb2'),
331
  'default' => '50'
332
  );
333
-
334
 
335
  // if(Helpers::userType()=="pro") {
336
 
@@ -354,12 +430,21 @@ if( !class_exists( 'Settings_Panel' ) ){
354
  'desc' => $info_tbl,
355
  'type' => 'html'
356
  );
 
 
 
 
 
 
 
 
 
357
  if(Helpers::userType()=="free") {
358
  $settingArr[]= array(
359
  'name' => $this->PREFIX.'upgrade-to-pro',
360
  'id' => $this->PREFIX.'upgrade-to-pro',
361
  'class' => $this->PREFIX.'settings-field',
362
- 'label' => 'Increase Translation Limit<br/>Using Pro License:',
363
  'desc' => $pro_info,
364
  'type' => 'html'
365
  );
@@ -474,10 +559,13 @@ if( !class_exists( 'Settings_Panel' ) ){
474
 
475
  $api_key = $this->ce_get_option( $this->PREFIX.'api-key');
476
 
 
477
  if( isset( $api_key ) && !empty( $api_key ) ){
478
  return;
479
  }
480
-
 
 
481
  // Show API message only in translation editor page
482
  if( isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit' ){
483
  $plugin_info = get_plugin_data( ATLT_FILE , true, true );
73
  <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
74
  </tr>
75
  </table>
76
+ <br/>
77
+ <span style="color:#0e840e;">*Check translation characters usage limit statistics inside API provider dashboard if you are using same API key on multiple sites.</span>';
78
  return $info_tbl;
79
  }
80
 
81
+ public function create_ibm_stats_tbl(){
82
+ $month = get_option('i_translation_month');
83
+ $total_translation = get_option('i_month_translated_chars', 0);
84
+ $a_per_mon=0;
85
+ $total_aval=0;
86
+ $a_per_mon=1000000;
87
+ $total_aval=$a_per_mon-$total_translation;
88
+ $info_tbl='<table>
89
+ <tr>
90
+ <th>Total Characters</th>
91
+ <th>'.number_format($a_per_mon).' / Month</th>
92
+ <th>Special Note</th>
93
+ </tr>
94
+ <tr>
95
+ <td><strong>Used Characters</strong></td>
96
+ <td>'.number_format($total_translation).'<br/><span>(Used This Month)</span></td>
97
+ <td rowspan="2" style="max-width:200px;">Plugin do not provide any free translation limit.
98
+ All free characters translation limit provided by translate API provider - <strong>IBM Watson</strong></td>
99
+ </tr>
100
+ <tr>
101
+ <td><strong>Available Characters</strong></td>
102
+ <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
103
+ </tr>
104
+ </table>
105
+ <br/>
106
+ <span style="color:#0e840e;">*Check translation characters usage limit statistics inside API provider dashboard if you are using same API key on multiple sites.</span>';
107
+ return $info_tbl;
108
+ }
109
+
110
 
111
  public function create_microsoft_stats_tbl(){
112
  $month = get_option('m_translation_month');
131
  <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
132
  </tr>
133
  </table>
134
+ <br/>
135
+ <span style="color:#0e840e;">*Check translation characters usage limit statistics inside API provider dashboard if you are using same API key on multiple sites.</span>';
136
  return $info_tbl;
137
  }
138
 
141
  $desc='';
142
  $sourceLang='en';
143
  $targetLang='fr';
144
+ $rawString='Hello';
145
+ $apiKey='';
146
  $ajax_url= admin_url( 'admin-ajax.php' );
147
  $nonce= wp_create_nonce('atlt_nonce');
148
+ if($name=="microsoft")
149
+ {
150
  $apiKey= Helpers::getAPIkey("microsoft");
151
  $lbl='Microsoft Translation';
152
  $desc='<a target="_blank" href="https://locotranslate.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');
156
+ $lbl='IBM Translation';
157
+ $desc='<a target="_blank" href="https://locoaddon.com/how-to-generate-ibm-watson-translator-api-key/">How to generate IBM Watson Translator free API key?</a>';
158
+
159
+ if(!empty($keys_arr['atlt_ibm-translate-api-key'])&&
160
+ !empty($keys_arr['atlt_ibm-translate-url'])){
161
+ $apiKey=$keys_arr['atlt_ibm-translate-api-key'];
162
+ $lbl='IBM Translate';
163
+ }
164
+
165
+ } else if($name=="google")
166
+ {
167
+ $apiKey= Helpers::getAPIkey("google");
168
+ $lbl='Google Translation';
169
+ $desc= '<a target="_blank" href="https://locotranslate.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';
173
+ $desc='<span style="color:#e00b0b;">*Yandex Translate API v1 has been deprecated from June 01, 2020. Yandex has stopped providing free translate API v1 keys.<br/>If you have already generated Yandex Translate v1 API key only then you can use Yandex for automatic translations.</span>';
174
  }
175
  if($apiKey){
176
  $output .='<div><a class="atlt_test_api button button-primary button-small"
185
  }else{
186
  $output.=$desc;
187
  }
188
+
189
  return $output;
190
+
191
+ }
192
  /*
193
  |--------------------------------------------------------------------
194
  | return all settings fields to be initialized in settings page
252
  <td>'.number_format($today_aval).'<br/><span>(Available Today)</span></td>
253
  <td>'.number_format($total_aval).'<br/><span>(Available This Month)</span></td>
254
  </tr>
255
+ </table>
256
+ <br/>
257
+ <span style="color:#e00b0b;">*Yandex Translate API v1 has been deprecated from June 01, 2020. Yandex has stopped providing free translate API v1 keys.<br>If you have already generated Yandex Translate v1 API key only then you can use Yandex for automtatic translations.</span>';
258
 
259
+ if( function_exists( 'loco_plugin_version' ) && version_compare( loco_plugin_version() , '2.3.3' , '>') ):
260
+ $settingArr[]= array(
261
+ 'name' => $this->PREFIX.'rollback-request',
262
+ 'id' => $this->PREFIX.'rollback-request',
263
+ 'class' => $this->PREFIX.'rollbakBtn',
264
+ 'label' => 'Rollback Loco Translate To Version 2.3.3:',
265
+ 'desc' => '<div id="Btloco_rollback" class="button primary">Rollback Here</div>
266
+ <p class="notices" style="color:#d61919;"><strong>Automatic Translate Addon For Loco Translate</strong> is only compatible with Loco Translate official plugin version <strong>2.3.3</strong> or lower.<br/>Currently you are using Loco Translate official plugin version 2.4.0 or higher.<br/>Please rollback to use all features of this addon.<br/><br/>You can also rollback via <a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback plugin</a> easily if you face any issue in above rollback process.</p>
267
+ ',
268
+ 'type' => 'html',
269
+ );
270
+ endif;
271
 
272
  $pro_per_day=1000000;
273
  $pro_per_mon=10000000;
274
  $pro_info='<table>
275
  <tr>
276
+ <th style="vertical-align:middle;">Google Translate API</th>
277
+ <td style="min-width:200px;">'.number_format(500000).' / Month<br/>(Free Char Limit)</td>
278
+ <td rowspan="2" style="max-width:200px;"><p>Free characters translation limit only provided by Translate API providers, e.g. - Google, Microsoft, IBM etc.<br/>Plugin doesn\'t provide any free characters limit for automatic translations.</p></td>
279
  </tr>
280
  <tr>
281
+ <th style="vertical-align:middle;">Microsoft Translator API</th>
282
+ <td style="min-width:200px;">'.number_format(2000000).' / Month<br/>(Free Char Limit)</td>
 
 
 
 
283
  </tr>
284
  </table>';
285
 
287
  'name' => $this->PREFIX.'api-key',
288
  'id' => $this->PREFIX.'api-key',
289
  'class' => $this->PREFIX.'settings-field',
290
+ 'label' => 'Enter Yandex Translate<br/>API v1 Key:',
291
  'desc' =>$this->APIIntegrationTesting("yandex"),
292
  'type' => 'text',
293
  'placeholder'=>__('Yandex API Key','cmb2'),
294
  'default' => ''
295
  );
296
+
297
+ $settingArr[]=array(
298
+ 'name' => $this->PREFIX.'ibm-translate-api-key',
299
+ 'id' => $this->PREFIX.'ibm-translate-api-key',
300
+ 'class' => $this->PREFIX.'settings-field',
301
+ 'label' => 'Enter IBM Translate<br/>API Key:',
302
+ 'type' => 'text',
303
+ 'placeholder'=>__('IBM Translate API Key','cmb2'),
304
+ 'default' => ''
305
+ );
306
+ $settingArr[]=array(
307
+ 'name' => $this->PREFIX.'ibm-translate-url',
308
+ 'id' => $this->PREFIX.'ibm-translate-url',
309
+ 'class' => $this->PREFIX.'settings-field',
310
+ 'label' => 'Enter IBM Translate URL:',
311
+ 'desc' =>$this->APIIntegrationTesting("ibm"),
312
+ 'type' => 'text',
313
+ 'placeholder'=>__('IBM Watson Translate URL','cmb2'),
314
+ 'default' => ''
315
+ );
316
  if(Helpers::userType()=="pro" && Helpers::proInstalled()==false) {
317
  $key=Helpers::getLicenseKey();
318
  $url =esc_url( add_query_arg( 'license-key',$key , 'https://locotranslate.com/data/download-plugin.php' ) );
407
  'placeholder'=>__('50','cmb2'),
408
  'default' => '50'
409
  );
 
410
 
411
  // if(Helpers::userType()=="pro") {
412
 
430
  'desc' => $info_tbl,
431
  'type' => 'html'
432
  );
433
+
434
+ $settingArr[]= array(
435
+ 'name' => $this->PREFIX.'ibm-traslation-limit',
436
+ 'id' => $this->PREFIX.'ibm-traslation-limit',
437
+ 'class' => $this->PREFIX.'settings-field',
438
+ 'label' => 'IBM Translate<br>Free Translation Limit:',
439
+ 'desc' =>$this->create_ibm_stats_tbl(),
440
+ 'type' => 'html'
441
+ );
442
  if(Helpers::userType()=="free") {
443
  $settingArr[]= array(
444
  'name' => $this->PREFIX.'upgrade-to-pro',
445
  'id' => $this->PREFIX.'upgrade-to-pro',
446
  'class' => $this->PREFIX.'settings-field',
447
+ 'label' => 'Extra Translate APIs Support<br/>Using Pro License:',
448
  'desc' => $pro_info,
449
  'type' => 'html'
450
  );
559
 
560
  $api_key = $this->ce_get_option( $this->PREFIX.'api-key');
561
 
562
+ $ibm_api_key = $this->ce_get_option( $this->PREFIX.'ibm-translate-api-key');
563
  if( isset( $api_key ) && !empty( $api_key ) ){
564
  return;
565
  }
566
+ if( isset( $ibm_api_key ) && !empty( $ibm_api_key ) ){
567
+ return;
568
+ }
569
  // Show API message only in translation editor page
570
  if( isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit' ){
571
  $plugin_info = get_plugin_data( ATLT_FILE , true, true );
includes/Helpers/Atlt_rollback.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LocoAutoTranslateAddon\Helpers;
3
+ /**
4
+ * This class is used to rollback a plugin. It extends wordpress core class Plugin_Upgrader
5
+ * Due to the use of package & namaspace, class can not be extend requiring file
6
+ *
7
+ */
8
+
9
+ if( !defined( 'ABSPATH' )){
10
+ die( 'WordPress enviornment not found!');
11
+ }
12
+
13
+ if( !class_exists( 'Plugin_Upgrader' ) ){
14
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
15
+ }
16
+
17
+ class Atlt_rollback extends \Plugin_Upgrader{
18
+
19
+ public function rollback(){
20
+
21
+ $key = ( isset( $_POST['key'] ) && !empty( $_POST['key'] ) ) ? $_POST['key'] : null;
22
+
23
+ if( $key == null || !wp_verify_nonce($key, 'atlt_nounce_rollback_loco')){
24
+ return 'Nonce verification failed!';
25
+ }
26
+
27
+ $this->init();
28
+ $this->upgrade_strings();
29
+
30
+ $url = 'https://downloads.wordpress.org/plugin/loco-translate.2.3.3.zip';
31
+
32
+ add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
33
+ add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
34
+
35
+ $this->run( array(
36
+ 'package' => $url,
37
+ 'destination' => WP_PLUGIN_DIR,
38
+ 'clear_destination' => true,
39
+ 'clear_working' => true,
40
+ 'hook_extra' => array(
41
+ 'plugin' => 'loco-translate',
42
+ 'type' => 'plugin',
43
+ 'action' => 'update',
44
+ ),
45
+ ) );
46
+
47
+ remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
48
+ remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
49
+
50
+ if ( ! $this->result || is_wp_error( $this->result ) ) {
51
+ return $this->result;
52
+ }
53
+ return 'Loco Translate rollback successful!';
54
+ }
55
+ }
includes/Helpers/Helpers.php CHANGED
@@ -50,6 +50,40 @@ class Helpers{
50
  return $month_total_translated;
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  // check timing
54
  public static function checkPeriod(){
55
  $today=get_transient('atlt_translation_day');
@@ -111,13 +145,20 @@ class Helpers{
111
  $a_per_mon=2000000;
112
  $total_translation = get_option('m_month_translated_chars', 0);
113
  $availableChars=$a_per_mon-$total_translation;
114
- }else{
 
 
 
 
 
 
115
  $a_per_mon=500000;
116
  $total_translation = get_option('g_month_translated_chars', 0);
117
  $availableChars=$a_per_mon-$total_translation;
118
  }
119
  return $availableChars;
120
  }
 
121
  public static function getAPIkey($source){
122
  $key='';
123
  $keys_arr= get_option('atlt_register');
@@ -129,6 +170,10 @@ class Helpers{
129
  if(isset($keys_arr['atlt_microsoft-api-key'])){
130
  $key=$keys_arr['atlt_microsoft-api-key'];
131
  }
 
 
 
 
132
  }else{
133
  if(isset($keys_arr['atlt_api-key'])){
134
  $key=$keys_arr['atlt_api-key'];
@@ -207,4 +252,17 @@ class Helpers{
207
  return false;
208
  }
209
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  }
50
  return $month_total_translated;
51
  }
52
 
53
+
54
+ /* google chars stats*/
55
+ public static function iTodayTranslated($value = 0)
56
+ {
57
+ $now_translated = $value;
58
+ if (false===($today= get_transient('i_translation_day'))) {
59
+ delete_option('i_perday_translated_chars');
60
+ update_option('i_perday_translated_chars', $now_translated);
61
+ set_transient('i_translation_day', 'true', DAY_IN_SECONDS);
62
+ $today_total_translated=$now_translated;
63
+ } else {
64
+ $already_translated = intval(get_option('i_perday_translated_chars'));
65
+ $today_total_translated = $already_translated+$now_translated;
66
+ update_option('i_perday_translated_chars', $today_total_translated);
67
+ }
68
+ return $today_total_translated;
69
+ }
70
+
71
+ // count monthly translated strings
72
+ public static function iMonthlyTranslated($value = 0){
73
+ $now_translated=$value;
74
+ if (false===($month= get_transient('i_translation_month'))) {
75
+ delete_option('i_month_translated_chars');
76
+ update_option('i_month_translated_chars',$now_translated);
77
+ set_transient('i_translation_month', 'true', MONTH_IN_SECONDS);
78
+ $month_total_translated=$now_translated;
79
+ } else {
80
+ $already_translated = intval(get_option('i_month_translated_chars'));
81
+ $month_total_translated= $already_translated+$now_translated;
82
+ update_option('i_month_translated_chars', $month_total_translated);
83
+ }
84
+ return $month_total_translated;
85
+ }
86
+
87
  // check timing
88
  public static function checkPeriod(){
89
  $today=get_transient('atlt_translation_day');
145
  $a_per_mon=2000000;
146
  $total_translation = get_option('m_month_translated_chars', 0);
147
  $availableChars=$a_per_mon-$total_translation;
148
+ }else if($source=="ibm"){
149
+ $a_per_mon=1000000;
150
+ $total_translation = get_option('i_month_translated_chars', 0);
151
+ $availableChars=$a_per_mon-$total_translation;
152
+ }
153
+
154
+ else{
155
  $a_per_mon=500000;
156
  $total_translation = get_option('g_month_translated_chars', 0);
157
  $availableChars=$a_per_mon-$total_translation;
158
  }
159
  return $availableChars;
160
  }
161
+
162
  public static function getAPIkey($source){
163
  $key='';
164
  $keys_arr= get_option('atlt_register');
170
  if(isset($keys_arr['atlt_microsoft-api-key'])){
171
  $key=$keys_arr['atlt_microsoft-api-key'];
172
  }
173
+ }else if($source=="ibm"){
174
+ if(isset($keys_arr['atlt_ibm-translate-api-key'])){
175
+ $key=$keys_arr['atlt_ibm-translate-api-key'];
176
+ }
177
  }else{
178
  if(isset($keys_arr['atlt_api-key'])){
179
  $key=$keys_arr['atlt_api-key'];
252
  return false;
253
  }
254
  }
255
+
256
+ public static function ibmSLangList($langCode,$list=false){
257
+ $json_lang_list='{"ar":"Arabic","bg":"Bulgarian","bn":"Bengali","cs":"Czech","da":"Danish","de":"German","el":"Greek","es":"Spanish","et":"Estonian","fi":"Finnish","fr":"French","ga":"Irish","gu":"Gujarati","he":"Hebrew","hi":"Hindi","hr":"Croatian","hu":"Hungarian","it":"Italian","ja":"Japanese","ko":"Korean","lt":"Lithuanian","lv":"Latvian","ml":"Malayalam","ms":"Malay","mt":"Maltese","nb":"Norwegian Bokmal","ne":"Nepali","nl":"Dutch","pl":"Polish","pt":"Portuguese","ro":"Romanian","ru":"Russian","si":"Sinhala","sk":"Slovakian","sl":"Slovenian","sv":"Swedish","ta":"Tamil","te":"Telugu","tr":"Turkish","uk":"Ukrainian","ur":"Urdu","vi":"Vietnamese","zh":"Simplified Chinese"}';
258
+ $langArr=json_decode($json_lang_list,true);
259
+ if($list){
260
+ return $langArr;
261
+ }
262
+ if(isset($langArr[$langCode])){
263
+ return true;
264
+ }else{
265
+ return false;
266
+ }
267
+ }
268
  }
includes/Register/LocoAutomaticTranslateAddonPro.php CHANGED
@@ -141,7 +141,7 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
141
  <?php
142
  }
143
  ?>
144
- <p><?php _e("Enter your license key below to <strong>increase auto translation limit</strong> 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;
@@ -156,17 +156,17 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
156
  <th>Premium License</th>
157
  </tr>
158
  <tr>
159
- <td>Yandex Translate API</td>
160
  <td>Available</td>
161
  <td>Available</td>
162
  </tr>
163
  <tr>
164
- <td>Yandex API - free translation limit</td>
165
- <td>300,000 char / day<br/>1,000,000 char / month</td>
166
- <td>1,000,000 char / day<br/>10,000,000 char / month</td>
167
  </tr>
168
  <tr>
169
- <td>Google Translate API</td>
170
  <td>Not Available</td>
171
  <td>Available</td>
172
  </tr>
@@ -175,7 +175,7 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
175
  <td>Not Available</td>
176
  <td>500,000 char / month</td>
177
  </tr>
178
- <td>Microsoft Translator API</td>
179
  <td>Not Available</td>
180
  <td>Available</td>
181
  </tr>
@@ -185,21 +185,21 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
185
  <td>2,000,000 char / month</td>
186
  </tr>
187
  <tr>
188
- <td>HTML Translation Support</td>
189
  <td>Not Available</td>
190
- <td>Available for Yandex API</td>
191
  </tr>
192
  <tr>
193
- <td>Reset Translations</td>
194
  <td>Not Available</td>
195
- <td>Available</td>
196
  </tr>
197
- <td>Support</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
- <p>Free characters translation limit only provided by Translate API providers, e.g. - Google, Microsoft, Yandex etc.<br/>Plugin don't provide any free characters limit for automatic translations.</p>
203
  <br/>
204
  <h3><a href='https://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Premium License Key - <strong>($18 - $88)</strong></a></h3>
205
  <br/>
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;
156
  <th>Premium License</th>
157
  </tr>
158
  <tr>
159
+ <td><strong>IBM Watson Language Translator API</strong></td>
160
  <td>Available</td>
161
  <td>Available</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>Google Translate API Support</strong></td>
170
  <td>Not Available</td>
171
  <td>Available</td>
172
  </tr>
175
  <td>Not Available</td>
176
  <td>500,000 char / month</td>
177
  </tr>
178
+ <td><strong>Microsoft Translator API Support</strong></td>
179
  <td>Not Available</td>
180
  <td>Available</td>
181
  </tr>
185
  <td>2,000,000 char / month</td>
186
  </tr>
187
  <tr>
188
+ <td><strong>Reset Translations</strong></td>
189
  <td>Not Available</td>
190
+ <td>Available</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
+ <p style="color:#e00b0b;">*Free characters translation limit only provided by Translate API providers, e.g. - Google, Microsoft, IBM etc.<br/>Plugin don't provide any free characters limit for automatic translations.<br/><br/>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.</p>
203
  <br/>
204
  <h3><a href='https://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Premium License Key - <strong>($18 - $88)</strong></a></h3>
205
  <br/>
includes/ReviewNotice/class.review-notice.php CHANGED
@@ -72,11 +72,11 @@ if (!class_exists('ALTLReviewNotice')) {
72
  $already_rated_text=esc_html__( 'I already rated it', 'atlt2' );
73
  $not_like_it_text=esc_html__( 'Not Interested', 'atlt2' );
74
  $p_link=esc_url('https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post');
75
- $pro_url=esc_url('https://eventscalendartemplates.com/');
76
 
77
  $message="Thanks for using <b>$p_name</b> - WordPress plugin. We hope it has saved your valuable time and efforts! <br/>Please give us a quick rating, it works as a boost for us to keep working on more <a href='https://coolplugins.net' target='_blank'><strong>Cool Plugins</strong></a>!<br/>";
78
 
79
- $html='<div data-ajax-url="%8$s" data-ajax-callback="%9$s" class="cool-feedback-notice-wrapper %1$s">
80
  <div class="logo_container"><a href="%5$s"><img src="%2$s" alt="%3$s" style="max-width:80px;"></a></div>
81
  <div class="message_container">%4$s
82
  <div class="callto_action">
72
  $already_rated_text=esc_html__( 'I already rated it', 'atlt2' );
73
  $not_like_it_text=esc_html__( 'Not Interested', 'atlt2' );
74
  $p_link=esc_url('https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post');
75
+ //$pro_url=esc_url('https://eventscalendartemplates.com/');
76
 
77
  $message="Thanks for using <b>$p_name</b> - WordPress plugin. We hope it has saved your valuable time and efforts! <br/>Please give us a quick rating, it works as a boost for us to keep working on more <a href='https://coolplugins.net' target='_blank'><strong>Cool Plugins</strong></a>!<br/>";
78
 
79
+ $html='<div data-ajax-url="%8$s" data-ajax-callback="%9$s" class="atlt-feedback-notice-wrapper %1$s">
80
  <div class="logo_container"><a href="%5$s"><img src="%2$s" alt="%3$s" style="max-width:80px;"></a></div>
81
  <div class="message_container">%4$s
82
  <div class="callto_action">
includes/ibm-translator/class.ibm-translator.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LocoAutoTranslateAddon;
3
+ class ibmTranslator {
4
+
5
+ public $queue = [];
6
+ public $response;
7
+ public $responses = [];
8
+
9
+ public function translate($args = [], $opts = []) {
10
+ $args['key'] = isset($args['key']) ? $args['key'] : null;
11
+ $args['from'] = isset($args['from']) ? $args['from'] : null;
12
+ $args['to'] = isset($args['to']) ? $args['to'] : null;
13
+ $args['text'] = isset($args['text']) ? $args['text'] : null;
14
+ if (!$args['base']) {
15
+ return false;
16
+ }
17
+ if (!$args['key']) {
18
+ return false;
19
+ }
20
+ if (!$args['from']) {
21
+ return false;
22
+ }
23
+ if (!$args['to']) {
24
+ return false;
25
+ }
26
+ if (!$args['text']) {
27
+ return false;
28
+ }
29
+ $url = $args['base'];
30
+
31
+ $headers = [
32
+ 'Content-type: application/json',
33
+ ];
34
+ $data['text']= $args['text'];
35
+ $data['source']= $args['from'];
36
+ $data['target']= $args['to'];
37
+ $params = json_encode($data);
38
+
39
+ $options = $opts;
40
+ $queue = isset($args['queue']) ? $args['queue'] : false;
41
+ $response = $this->post($url, $headers, $params, $options, $queue,$args['key']);
42
+ if (!$queue) {
43
+ $this->response = $response;
44
+ }
45
+ if ($queue) {
46
+ return;
47
+ }
48
+ $json = json_decode($response['body'], true);
49
+ $response=[];
50
+ if(isset($json['code'])&& isset($json['error'])){
51
+ $response['code']=$json['code'];
52
+ $response['error']=$json['error'];
53
+ }else{
54
+ $response['code']=200;
55
+
56
+ if (empty($json['translations'][0]['translation'])) {
57
+ return false;
58
+ }
59
+ if(is_array($json['translations'])){
60
+ foreach($json['translations'] as $key=>$value){
61
+ $translated[$key]=$value['translation'];
62
+ }
63
+ $response['translation']=$translated;
64
+ }
65
+ }
66
+ return $response;
67
+ }
68
+
69
+ public function post($url, $headers = [], $params = [], $options = [], $queue = false,$api_key) {
70
+ $opts = [];
71
+ $opts[CURLINFO_HEADER_OUT] = true;
72
+ $opts[CURLOPT_CONNECTTIMEOUT] = 5;
73
+ $opts[CURLOPT_ENCODING] = '';
74
+ $opts[CURLOPT_FOLLOWLOCATION] = false;
75
+ $opts[CURLOPT_HEADER] = true;
76
+ $opts[CURLOPT_HTTPHEADER] = $headers;
77
+ $opts[CURLOPT_POST] = true;
78
+ //$opts[CURLOPT_USERPWD] = \json_encode(array('api_key'=>$api_key));
79
+ $opts[CURLOPT_POSTFIELDS] = is_array($params) || is_object($params) ? http_build_query($params) : $params;
80
+ $opts[CURLOPT_RETURNTRANSFER] = true;
81
+ $opts[CURLOPT_SSL_VERIFYHOST] = false;
82
+ $opts[CURLOPT_SSL_VERIFYPEER] = false;
83
+ $opts[CURLOPT_TIMEOUT] = 10;
84
+ $opts[CURLOPT_URL] = $url;
85
+ foreach ($opts as $key => $value) {
86
+ if (!array_key_exists($key, $options)) {
87
+ $options[$key] = $value;
88
+ }
89
+ }
90
+ if ($queue) {
91
+ $this->queue[] = ['options' => $options];
92
+ return;
93
+ }
94
+ $follow = false;
95
+ if ($options[CURLOPT_FOLLOWLOCATION]) {
96
+ $follow = true;
97
+ $options[CURLOPT_FOLLOWLOCATION] = false;
98
+ }
99
+ $errors = 2;
100
+ $redirects = isset($options[CURLOPT_MAXREDIRS]) ? $options[CURLOPT_MAXREDIRS] : 5;
101
+ while (true) {
102
+ $ch = curl_init();
103
+ curl_setopt_array($ch, $options);
104
+ curl_setopt($ch, CURLOPT_USERPWD, 'apikey' . ':' .$api_key );
105
+ $body = curl_exec($ch);
106
+ $info = curl_getinfo($ch);
107
+ $head = substr($body, 0, $info['header_size']);
108
+ $body = substr($body, $info['header_size']);
109
+ $error = curl_error($ch);
110
+ $errno = curl_errno($ch);
111
+ curl_close($ch);
112
+ $response = [
113
+ 'info' => $info,
114
+ 'head' => $head,
115
+ 'body' => $body,
116
+ 'error' => $error,
117
+ 'errno' => $errno,
118
+ ];
119
+ if ($error || $errno) {
120
+ if ($errors > 0) {
121
+ $errors--;
122
+ continue;
123
+ }
124
+ } elseif ($info['redirect_url'] && $follow) {
125
+ if ($redirects > 0) {
126
+ $redirects--;
127
+ $options[CURLOPT_URL] = $info['redirect_url'];
128
+ continue;
129
+ }
130
+ }
131
+ break;
132
+ }
133
+ return $response;
134
+ }
135
+
136
+ }
readme.txt CHANGED
@@ -1,42 +1,40 @@
1
- === Automatic Translate Addon For Loco Translate ===
2
  Contributors:narinder-singh
3
  Donate link: https://paypal.me/CoolPlugins/10USD/
4
  Tags:loco,translate,translation,translator,localization,language,translations,loco translate,loco addon
5
  Requires at least:4.5
6
- Tested up to:5.4
7
  Requires PHP:5.6
8
  Stable tag:trunk
9
  License:GPLv2 or later
10
  License URI:http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
- Automatic language translator add-on for Loco Translate plugin to translate WordPress plugins and themes translation files.
13
 
14
  == Description ==
15
 
16
- > **Important Notice:-** All features of this addon has been integrated inside **Loco Translate** official plugin (version 2.4.0+) so there is no requirement to use this addon along with Loco official plugin(2.4.0+), If you want to use this addon then Loco Translate official plugin version must be less than 2.4.0
17
-
18
- **This addon is compatible with Loco Translate official plugin version less than 2.4.0**
19
 
20
  **Automatic Machine Translator Addon For Loco Translate**
21
 
22
  Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)**(< 2.4.0) plugin (**1,000,000+ Active Installations**) and automatically machine translate any WordPress plugin or theme translation files into any language.
23
 
24
- This addon supports Yandex Translate API for free users and Yandex, Google & Microsoft Translator APIs for premium users.
25
 
26
  = Loco Addon Features: =
27
  * One-click translate any plugin or theme all translatable strings.
28
- * You can automatic translate upto **300,000 characters** daily free of cost using Yandex API (you can extend this limit via [premium license key](https://locotranslate.com/addon/loco-automatic-translate-premium-license-key/)).
29
  * Check auto translations inside Loco build-in editor to manually edit any machine translated string.
30
- * This plugin uses **[Yandex.Translate](http://translate.yandex.com/)** API to auto translate plugin / theme language(po) files. Grab free api key:- [https://translate.yandex.com/developers/keys](https://translate.yandex.com/developers/keys)
31
- * Pro version also supports Google & Microsoft Translator APIs.
32
 
33
  > “If you spend too much time thinking about a thing, you'll never get it done. Stop wasting time, complete work smartly & quickly!”
34
 
35
  = FREE v/s Premium License Key Comparison: =
36
  **Free License**
37
 
38
- * ✅ **Yandex Translate Support:** Available
39
- * ✅ **Yandex API Free Translation Limit:** 300,000 char / day<br/>1,000,000 char / month
40
  * ❌ **Google Translate Support:** Not Available
41
  * ❌ **Google API Free Translation Limit:** Not Available
42
  * ❌ **Microsoft Translator Support:** Not Available
@@ -47,17 +45,19 @@ This addon supports Yandex Translate API for free users and Yandex, Google & Mic
47
 
48
  **Premium License**
49
 
50
- * ✅ **Yandex Translate Support:** Available
51
- * ✅ **Yandex API Free Translation Limit:** 1,000,000 char / day<br/>10,000,000 char / month
52
  * ✅ **Google Translate Support:** Available
53
  * ✅ **Google API Free Translation Limit:** 500,000 char / month
54
  * ✅ **Microsoft Translator Support:** Available
55
  * ✅ **Microsoft API Free Translation Limit:** 2,000,000 char / month
56
  * ✅ **Reset Translations:** Available
57
- * ✅ **HTML Translations:** Available for Yandex Translate API
58
  * ✅ **Premium Support:** Quick support via email - contact@coolplugins.net (**Support time:- 24-48 hours**)
59
  * **Buy Premium License:** [$18 - $88](https://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing)
60
 
 
 
61
  > “Many people make the mistake of saving money by wasting time.”
62
 
63
  https://www.youtube.com/watch?v=pjKNbkQNQDU
@@ -71,16 +71,16 @@ We(**CoolPlugins.net**) only manage [LocoTranslate.com](https://locotranslate.co
71
  > We provide cool solutions to remove famous plugins limitations!
72
 
73
  = Special THANKS!: =
74
- Special thanks to famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin authors **Tim** for creating an awesome plugin for translations, we have forked some js files from main Loco Translate plugin to create this addon and also thanks to Yandex for providing translate API.
75
 
76
- All automatic translations will machine translations, powered by Yandex Translate API, so we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site.
77
  [](http://coderisk.com/wp/plugin/automatic-translator-addon-for-loco-translate/RIPS-FN0AdXlllg)
78
  == Installation ==
79
  1. Install **Loco Automatic Translate Addon** from the WordPress.org repository or by uploading plugin-zip unzipped folder to the **/wp-content/plugins** directory. You must also install **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** free plugin if you want to use this addon.
80
 
81
  2. Activate the plugin through **Plugins >> Installed Plugin** menu in WordPress
82
 
83
- 3. After plugin activation you need to insert Yandex API key inside **Loco Translate >> Auto Translator Addon - Settings**. You can grab a free api key at here:- [https://translate.yandex.com/developers/keys](https://translate.yandex.com/developers/keys)
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
 
@@ -88,38 +88,44 @@ All automatic translations will machine translations, powered by Yandex Translat
88
 
89
  == Frequently Asked Questions ==
90
  = How it works? =
91
- This plugin works as an addon for **Loco Translate** plugin. First you need to install and activate free version of "Loco translate" then install this addon and use one-click machine translations (supported by Yandex API).
92
 
93
  = Are you using any language translation API? =
94
- Free license users can only use - **[Yandex Translate API](https://tech.yandex.com/translate/)**, you can read more about its terms to use at here - https://yandex.com/legal/translate_api/
95
- Also grab a free API key at here:- [https://translate.yandex.com/developers/keys](https://translate.yandex.com/developers/keys)
96
 
97
- API Terms Of Service :- [https://translate.yandex.com/developers/offer](https://translate.yandex.com/developers/offer)
98
  But if you are using a premium license then you can also use Google Translate API and Microsoft Translator API
99
 
100
  = Is there any translation limit? =
101
- **Free license** users:- can only translate 300,000 characters per day but not more than 1,000,000 per month using Yandex API.
102
  No support available for Google or Microsoft Translator API for free users.
103
 
104
- **Premium license** users:- can translate 1,000,000 characters per day but not more than 10,000,000 per month using Yandex API.
105
  Google Translate API provides free 500,000 char / month for translations.
106
  Microsoft Translator API provides free 2,000,000 char / month for translations.
107
 
108
- *This plugin does not provide free characters for translation. It only provides settings to manage translation APIs (Yandex, Google, Microsoft etc.). Free characters translation availability only depends on the API providers (Yandex, Google, Microsoft etc.) terms and they can change it anytime.
109
-
110
 
111
  == Screenshots ==
112
- 1. Translate Using Yandex Translate API
113
  2. Loco Automatic Translate Addon Settings
114
  3. Free License v/s Premium License
115
  4. Free Translation Limit by API Providers
116
 
117
  == Changelog ==
118
- <strong>Version 1.7.4 | 27 MAY 2020</strong>
119
  <pre>
120
- Fixed:Admin notice bug
121
- </pre>
 
 
 
122
 
 
 
 
 
 
 
123
  <strong>Version 1.7.3 | 15 MAY 2020</strong>
124
  <pre>
125
  Updates:Minor Textual changes
1
+ === Automatic Translate Addon For Loco Translate 2.3.3 ===
2
  Contributors:narinder-singh
3
  Donate link: https://paypal.me/CoolPlugins/10USD/
4
  Tags:loco,translate,translation,translator,localization,language,translations,loco translate,loco addon
5
  Requires at least:4.5
6
+ Tested up to:5.4.2
7
  Requires PHP:5.6
8
  Stable tag:trunk
9
  License:GPLv2 or later
10
  License URI:http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ Automatic language translator add-on for Loco Translate plugin version 2.3.3 or lower to translate WordPress plugins and themes translation files.
13
 
14
  == Description ==
15
 
16
+ > **Important Notice:-** This addon is only compatible with Loco Translate official plugin version 2.3.3 or lower. If you are using Loco Translate(2.4.0+) then you can rollback your Loco Translate official plugin to an older version to use this addon.
 
 
17
 
18
  **Automatic Machine Translator Addon For Loco Translate**
19
 
20
  Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)**(< 2.4.0) plugin (**1,000,000+ Active Installations**) and automatically machine translate any WordPress plugin or theme translation files into any language.
21
 
22
+ This addon provides support to use IBM Watson Translator API for free users and Google & Microsoft Translator APIs for premium users.
23
 
24
  = Loco Addon Features: =
25
  * One-click translate any plugin or theme all translatable strings.
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://locotranslate.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
 
33
  = FREE v/s Premium License Key Comparison: =
34
  **Free License**
35
 
36
+ * ✅ **IBM Watson Translator Support:** Available
37
+ * ✅ **IBM Watson Translator API Free Translation Limit:** 1,000,000 char / month
38
  * ❌ **Google Translate Support:** Not Available
39
  * ❌ **Google API Free Translation Limit:** Not Available
40
  * ❌ **Microsoft Translator Support:** Not Available
45
 
46
  **Premium License**
47
 
48
+ * ✅ **IBM Watson Translator Support:** Available
49
+ * ✅ **IBM Watson Translator API Free Translation Limit:** 1,000,000 char / month
50
  * ✅ **Google Translate Support:** Available
51
  * ✅ **Google API Free Translation Limit:** 500,000 char / month
52
  * ✅ **Microsoft Translator Support:** Available
53
  * ✅ **Microsoft API Free Translation Limit:** 2,000,000 char / month
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://locotranslate.com/addon/loco-automatic-translate-premium-license-key/#pricing)
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
+
61
  > “Many people make the mistake of saving money by wasting time.”
62
 
63
  https://www.youtube.com/watch?v=pjKNbkQNQDU
71
  > We provide cool solutions to remove famous plugins limitations!
72
 
73
  = Special THANKS!: =
74
+ Special thanks to famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin authors **Tim** for creating an awesome plugin for translations, we have forked some js files from main Loco Translate plugin to create this addon and also thanks to IBM Watson for providing free translate API.
75
 
76
+ All automatic translations will machine translations, powered by IBM Watson Translator API, so we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site.
77
  [](http://coderisk.com/wp/plugin/automatic-translator-addon-for-loco-translate/RIPS-FN0AdXlllg)
78
  == Installation ==
79
  1. Install **Loco Automatic Translate Addon** from the WordPress.org repository or by uploading plugin-zip unzipped folder to the **/wp-content/plugins** directory. You must also install **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** free plugin if you want to use this addon.
80
 
81
  2. Activate the plugin through **Plugins >> Installed Plugin** menu in WordPress
82
 
83
+ 3. After plugin activation you need to insert IBM Watson API key inside **Loco Translate >> Auto Translator Addon - Settings**. You can grab a free api key by following these steps:- [https://locoaddon.com/how-to-generate-ibm-watson-translator-api-key/](https://locoaddon.com/how-to-generate-ibm-watson-translator-api-key/)
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
 
88
 
89
  == Frequently Asked Questions ==
90
  = How it works? =
91
+ This plugin works as an addon for **Loco Translate** plugin. First you need to install and activate free version of "Loco translate" then install this addon and use one-click machine translations (supported by IBM Watson Translator API).
92
 
93
  = Are you using any language translation API? =
94
+ Free license users can use - **[IBM Watson Translator API](https://www.ibm.com/in-en/cloud/watson-language-translator/)**, you can read more about its pricing terms to use at here - https://www.ibm.com/cloud/watson-language-translator/pricing You can get free API key by following these steps - [Click Here](https://locoaddon.com/how-to-generate-ibm-watson-translator-api-key/)
 
95
 
 
96
  But if you are using a premium license then you can also use Google Translate API and Microsoft Translator API
97
 
98
  = Is there any translation limit? =
99
+ **Free license** users:- can only translate 1,000,000 characters per month free of cost by using IBM Watson translator api.
100
  No support available for Google or Microsoft Translator API for free users.
101
 
102
+ **Premium license** users:- can also use Google & Microsoft translate apis.
103
  Google Translate API provides free 500,000 char / month for translations.
104
  Microsoft Translator API provides free 2,000,000 char / month for translations.
105
 
106
+ *This plugin does not provide free characters for translation. It only provides settings to manage translation APIs (IBM Watson, Google, Microsoft etc.). Free characters translation availability only depends on the API providers (IBM Watson, Google, Microsoft etc.) terms and they can change it anytime.
 
107
 
108
  == Screenshots ==
109
+ 1. Translate Using IBM Watson Translate API
110
  2. Loco Automatic Translate Addon Settings
111
  3. Free License v/s Premium License
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.
118
+ 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>
126
+ Fixed: notice bug fixed
127
+ Updated:Minor settings updates
128
+ </pre>
129
  <strong>Version 1.7.3 | 15 MAY 2020</strong>
130
  <pre>
131
  Updates:Minor Textual changes