Automatic Translate Addon For Loco Translate - Version 2.1

Version Description

Download this release

Release Info

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

Code changes from version 2.0.1 to 2.1

assets/css/custom.css CHANGED
@@ -1,236 +1,320 @@
1
  #cool-auto-translate-btn:before {
2
- padding-right: 5px !IMPORTANT;
3
- }
4
- #cool-auto-translate-btn:after{
5
- content: "No API Required!";
6
- clear: both;
7
- display: block;
8
- font-size: 10px;
9
- font-weight: bold;
10
- font-family: monospace;
11
- position: absolute;
12
- bottom: -6px;
13
- left: -1px;
14
- background: #129412;
15
- width: calc(100% + 2px);
16
- height: 12px;
17
- line-height: 12px;
18
- color: #fff;
19
- text-align: center;
20
- border-radius: 0 0 4px 4px;
21
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  /*form fieldset button.button.has-icon.icon-robot:after {
23
- content: "API Required!";
24
- clear: both;
25
- display: block;
26
- font-size: 9px;
27
- font-weight: bold;
28
- font-family: monospace;
29
- position: absolute;
30
- bottom: -6px;
31
- left: -1px;
32
- background: #403c3c;
33
- width: calc(100% + 2px);
34
- height: 12px;
35
- line-height: 12px;
36
- color: #fff;
37
- text-align: center;
38
- border-radius: 0 0 4px 4px;
39
  }*/
40
 
41
-
42
  span.proonly-button {
43
- background: #555;
44
- color: #fff;
45
- font-size: 12px;
46
- font-weight: bold;
47
- font-family: monospace;
48
- padding: 3px;
49
- border-radius: 3px;
50
- display: inline-block;
51
- margin: 2px 10px;
52
  }
 
53
  span.proonly-button a {
54
- color: #fff;
55
- text-decoration: none;
56
  }
 
57
  span.proonly-button.alsofree {
58
- background: green;
59
  }
60
 
 
 
 
 
61
 
62
  #atlt_strings_model {
63
- display: none;
64
- position: fixed;
65
- z-index: 99999;
66
- top: 0;
67
- width: 100%;
68
- height: 100vh;
69
- overflow: hidden;
70
- background-color: rgba(0, 0, 0, 0.75);
71
  }
 
72
  #atlt_strings_model .modal-content {
73
- position: relative;
74
- background-color: #fefefe;
75
- width: 80%;
76
- height: calc(100% - 40px);
77
- margin: 32px auto 0;
78
- overflow: hidden;
79
- border-radius: 5px;
80
- box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
81
- -webkit-animation-name: animatetop;
82
- -webkit-animation-duration: 0.4s;
83
- animation-name: animatetop;
84
- animation-duration: 0.4s;
85
  }
 
86
  @-webkit-keyframes animatetop {
87
- from {top:-300px; opacity:0}
88
- to {top:0; opacity:1}
 
 
 
 
 
 
89
  }
 
90
  @keyframes animatetop {
91
- from {top:-300px; opacity:0}
92
- to {top:0; opacity:1}
 
 
 
 
 
 
93
  }
94
 
95
-
96
  #atlt_strings_model .modal-header {
97
- padding: 2px 16px;
98
- background-color: #5cb85c;
99
- color: white;
100
- height: 86px;
101
- max-height: 86px;
102
- overflow: hidden;
103
- position: relative;
104
  }
 
105
  #atlt_strings_model .modal-header h2 {
106
- display: inline-block;
107
- font-size: 18px;
108
- color: #000;
109
- padding: 0;
110
- margin: 18px 159px 5px 0px;
111
- width: calc(100% - 160px);
112
  }
 
 
113
  /* The Close Button */
 
114
  #atlt_strings_model .modal-header .close {
115
- color: white;
116
- font-size: 28px;
117
- font-weight: bold;
118
- position: absolute;
119
- right: 10px;
120
- top: 20px;
121
  }
 
122
  #atlt_strings_model .modal-header .close:hover,
123
  #atlt_strings_model .modal-header .close:focus {
124
- color: #000;
125
- text-decoration: none;
126
- cursor: pointer;
127
  }
 
128
  #atlt_strings_model .save_btn_cont {
129
- margin: 8px;
130
- position: absolute;
131
- top: 10px;
132
- right: 40px;
133
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  #atlt_strings_model .ytstats {
135
- padding: 0;
136
- margin: 5px 160px 5px 0;
137
- width: calc(100% - 160px);
138
  }
 
139
  #atlt_strings_model .ytstats a {
140
- color: #fff936;
141
  }
142
 
143
-
144
  #atlt_strings_model .modal-body {
145
- padding: 2px 16px;
146
- position: relative;
147
  }
 
148
  #atlt_strings_model .notice-dismiss {
149
- padding:0;
150
  }
 
151
  #atlt_strings_model h3 {
152
- width: 100%;
153
- display: inline-block;
154
- font-size: 20px;
155
- padding: 0;
156
- margin: 20px 0 0;
 
157
  }
 
158
  #translate_element {
159
- margin-bottom: 25px;
160
  }
 
161
  #atlt_strings_model .string_container {
162
- overflow-y: scroll;
163
- overflow-x: hidden;
164
- height: calc(100vh - 460px);
165
- width: 100%;
166
- position: relative;
167
  }
 
168
  #atlt_strings_model table {
169
- border-spacing: 0;
170
- border-collapse: collapse;
171
- width: 100%;
172
- max-width: 100%;
173
- table-layout: fixed;
174
- padding:0;
175
- margin:0;
176
- }
177
- #atlt_strings_model table td:first-child, #atlt_strings_model table th:first-child {
178
- width: 60px;
179
- text-align: center;
180
- }
181
- #atlt_strings_model table td, #atlt_strings_model table th {
182
- border: 1px solid #ddd;
183
- padding: 4px;
184
- height: 26px;
185
- text-align: left;
186
- white-space: nowrap;
187
- font-size: 12px;
188
- line-height: 14px;
189
- overflow: hidden;
190
- vertical-align: middle;
191
  }
192
- #atlt_strings_model .my_translate_progress {
193
- position: absolute;
194
- display: none;
195
- top: 0;
196
- left: 10px;
197
- color: #fff;
198
- background: rgba(0, 0, 0, 0.5);
199
- width: calc(100% - 22px);
200
- border-radius: 3px;
201
- height: 100%;
202
- z-index: 9;
203
- box-sizing: border-box;
204
- font-size: 16px;
205
- line-height: 20px;
206
- font-weight: bold;
207
- text-align: center;
208
- padding-top: 30px;
209
  }
210
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
- #atlt_strings_model .modal-footer {
213
- padding: 2px 16px;
214
- background-color: #5cb85c;
215
- color: white;
216
- position: absolute;
217
- width: calc(100% - 32px);
218
- bottom: 0;
219
- height: 66px;
220
- max-height: 66px;
 
 
 
 
 
 
 
 
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
223
 
224
  .goog-te-banner-frame.skiptranslate {
225
- display: none !important;
226
- }
 
227
  .goog-te-combo option:first-child {
228
- display: none;
229
  }
230
 
231
  #yt-widget .yt-listbox__text {
232
- line-height: 14px !important;
233
- }
234
- #yt-widget .yt-listbox__input:not(:checked) ~ .yt-listbox__text{
235
- display: none !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  }
1
  #cool-auto-translate-btn:before {
2
+ padding-right: 5px !IMPORTANT;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  }
4
+
5
+ #cool-auto-translate-btn:after {
6
+ content: "No API Required!";
7
+ clear: both;
8
+ display: block;
9
+ font-size: 10px;
10
+ font-weight: bold;
11
+ font-family: monospace;
12
+ position: absolute;
13
+ bottom: -6px;
14
+ left: -1px;
15
+ background: #129412;
16
+ width: calc(100% + 2px);
17
+ height: 12px;
18
+ line-height: 12px;
19
+ color: #fff;
20
+ text-align: center;
21
+ border-radius: 0 0 4px 4px;
22
+ }
23
+
24
+
25
  /*form fieldset button.button.has-icon.icon-robot:after {
26
+ content: "API Required!";
27
+ clear: both;
28
+ display: block;
29
+ font-size: 9px;
30
+ font-weight: bold;
31
+ font-family: monospace;
32
+ position: absolute;
33
+ bottom: -6px;
34
+ left: -1px;
35
+ background: #403c3c;
36
+ width: calc(100% + 2px);
37
+ height: 12px;
38
+ line-height: 12px;
39
+ color: #fff;
40
+ text-align: center;
41
+ border-radius: 0 0 4px 4px;
42
  }*/
43
 
 
44
  span.proonly-button {
45
+ background: #555;
46
+ color: #fff;
47
+ font-size: 12px;
48
+ font-weight: bold;
49
+ font-family: monospace;
50
+ padding: 3px;
51
+ border-radius: 3px;
52
+ display: inline-block;
53
+ margin: 2px 10px;
54
  }
55
+
56
  span.proonly-button a {
57
+ color: #fff;
58
+ text-decoration: none;
59
  }
60
+
61
  span.proonly-button.alsofree {
62
+ background: green;
63
  }
64
 
65
+ span.proonly-button.alsofree img {
66
+ filter: brightness(10);
67
+ -webkit-filter: brightness(10);
68
+ }
69
 
70
  #atlt_strings_model {
71
+ display: none;
72
+ position: fixed;
73
+ z-index: 99999;
74
+ top: 0;
75
+ width: 100%;
76
+ height: 100vh;
77
+ overflow: hidden;
78
+ background-color: rgba(0, 0, 0, 0.75);
79
  }
80
+
81
  #atlt_strings_model .modal-content {
82
+ position: relative;
83
+ background-color: #fefefe;
84
+ width: 80%;
85
+ height: calc(100% - 40px);
86
+ margin: 32px auto 0;
87
+ overflow: hidden;
88
+ border-radius: 5px;
89
+ box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
90
+ -webkit-animation-name: animatetop;
91
+ -webkit-animation-duration: 0.4s;
92
+ animation-name: animatetop;
93
+ animation-duration: 0.4s;
94
  }
95
+
96
  @-webkit-keyframes animatetop {
97
+ from {
98
+ top: -300px;
99
+ opacity: 0
100
+ }
101
+ to {
102
+ top: 0;
103
+ opacity: 1
104
+ }
105
  }
106
+
107
  @keyframes animatetop {
108
+ from {
109
+ top: -300px;
110
+ opacity: 0
111
+ }
112
+ to {
113
+ top: 0;
114
+ opacity: 1
115
+ }
116
  }
117
 
 
118
  #atlt_strings_model .modal-header {
119
+ padding: 2px 16px;
120
+ background-color: #5cb85c;
121
+ color: white;
122
+ height: 86px;
123
+ max-height: 86px;
124
+ overflow: hidden;
125
+ position: relative;
126
  }
127
+
128
  #atlt_strings_model .modal-header h2 {
129
+ display: inline-block;
130
+ font-size: 18px;
131
+ color: #000;
132
+ padding: 0;
133
+ margin: 18px 159px 5px 0px;
134
+ width: calc(100% - 160px);
135
  }
136
+
137
+
138
  /* The Close Button */
139
+
140
  #atlt_strings_model .modal-header .close {
141
+ color: white;
142
+ font-size: 28px;
143
+ font-weight: bold;
144
+ position: absolute;
145
+ right: 10px;
146
+ top: 20px;
147
  }
148
+
149
  #atlt_strings_model .modal-header .close:hover,
150
  #atlt_strings_model .modal-header .close:focus {
151
+ color: #000;
152
+ text-decoration: none;
153
+ cursor: pointer;
154
  }
155
+
156
  #atlt_strings_model .save_btn_cont {
157
+ margin: 8px;
158
+ position: absolute;
159
+ top: 10px;
160
+ right: 40px;
161
  }
162
+
163
+ #atlt_strings_model .save_btn_cont button:not([disabled]):before {
164
+ font-family: dashicons;
165
+ content: "\f345";
166
+ display: inline-block;
167
+ font-size: 24px;
168
+ line-height: 26px;
169
+ vertical-align: middle;
170
+ left: -20px;
171
+ position: absolute;
172
+ color: #fff;
173
+ animation: moveit 5s infinite;
174
+ -webkit-animation: moveit 1s infinite;
175
+ }
176
+
177
+ @keyframes moveit {
178
+ from {
179
+ left: -22px;
180
+ }
181
+ to {
182
+ left: -10px;
183
+ }
184
+ }
185
+
186
  #atlt_strings_model .ytstats {
187
+ padding: 0;
188
+ margin: 5px 160px 5px 0;
189
+ width: calc(100% - 160px);
190
  }
191
+
192
  #atlt_strings_model .ytstats a {
193
+ color: #fff936;
194
  }
195
 
 
196
  #atlt_strings_model .modal-body {
197
+ padding: 2px 16px;
198
+ position: relative;
199
  }
200
+
201
  #atlt_strings_model .notice-dismiss {
202
+ padding: 0;
203
  }
204
+
205
  #atlt_strings_model h3 {
206
+ width: 100%;
207
+ display: inline-block;
208
+ font-size: 22px;
209
+ padding: 0;
210
+ margin: 20px 0 10px;
211
+ color: #5cb85c;
212
  }
213
+
214
  #translate_element {
215
+ margin-bottom: 25px;
216
  }
217
+
218
  #atlt_strings_model .string_container {
219
+ overflow-y: scroll;
220
+ overflow-x: hidden;
221
+ height: calc(100vh - 460px);
222
+ width: 100%;
223
+ position: relative;
224
  }
225
+
226
  #atlt_strings_model table {
227
+ border-spacing: 0;
228
+ border-collapse: collapse;
229
+ width: 100%;
230
+ max-width: 100%;
231
+ table-layout: fixed;
232
+ padding: 0;
233
+ margin: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  }
235
+
236
+ #atlt_strings_model table td:first-child,
237
+ #atlt_strings_model table th:first-child {
238
+ width: 60px;
239
+ text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
240
  }
241
 
242
+ #atlt_strings_model table td,
243
+ #atlt_strings_model table th {
244
+ border: 1px solid #ddd;
245
+ padding: 4px;
246
+ height: 26px;
247
+ text-align: left;
248
+ white-space: nowrap;
249
+ font-size: 12px;
250
+ line-height: 14px;
251
+ overflow: hidden;
252
+ vertical-align: middle;
253
+ }
254
 
255
+ #atlt_strings_model .my_translate_progress {
256
+ position: absolute;
257
+ display: none;
258
+ top: 0;
259
+ left: 10px;
260
+ color: #fff;
261
+ background: rgba(0, 0, 0, 0.5);
262
+ width: calc(100% - 22px);
263
+ border-radius: 3px;
264
+ height: 100%;
265
+ z-index: 9;
266
+ box-sizing: border-box;
267
+ font-size: 16px;
268
+ line-height: 20px;
269
+ font-weight: bold;
270
+ text-align: center;
271
+ padding-top: 30px;
272
  }
273
 
274
+ #atlt_strings_model .modal-footer {
275
+ padding: 2px 16px;
276
+ background-color: #5cb85c;
277
+ color: white;
278
+ position: absolute;
279
+ width: calc(100% - 32px);
280
+ bottom: 0;
281
+ height: 66px;
282
+ max-height: 66px;
283
+ }
284
 
285
  .goog-te-banner-frame.skiptranslate {
286
+ display: none !important;
287
+ }
288
+
289
  .goog-te-combo option:first-child {
290
+ display: none;
291
  }
292
 
293
  #yt-widget .yt-listbox__text {
294
+ line-height: 14px !important;
295
+ }
296
+
297
+ #yt-widget .yt-listbox__input:not(:checked)~.yt-listbox__text {
298
+ display: none !important;
299
+ }
300
+
301
+ #loco-hint .loco-api.loco-api-loco_auto {
302
+ display: none;
303
+ }
304
+
305
+ html.merge-translations:before {
306
+ position: fixed;
307
+ width: 100%;
308
+ height: 100%;
309
+ background: rgb(0, 0, 0, 0.9);
310
+ z-index: 9999990;
311
+ content: "Merging Translations.....";
312
+ color: #fff;
313
+ font-size: 28px;
314
+ text-align: center;
315
+ padding-top: 50px;
316
+ }
317
+
318
+ .ui-dialog.loco-modal.ui-draggable.addtranslations {
319
+ border: 6px solid #5cb85c;
320
  }
assets/css/custom.min.css CHANGED
@@ -1 +1 @@
1
- #cool-auto-translate-btn:before{padding-right:5px!important}#cool-auto-translate-btn:after{content:"No API Required!";clear:both;display:block;font-size:10px;font-weight:700;font-family:monospace;position:absolute;bottom:-6px;left:-1px;background:#129412;width:calc(100% + 2px);height:12px;line-height:12px;color:#fff;text-align:center;border-radius:0 0 4px 4px}span.proonly-button{background:#555;color:#fff;font-size:12px;font-weight:700;font-family:monospace;padding:3px;border-radius:3px;display:inline-block;margin:2px 10px}span.proonly-button a{color:#fff;text-decoration:none}span.proonly-button.alsofree{background:green}#atlt_strings_model{display:none;position:fixed;z-index:99999;top:0;width:100%;height:100vh;overflow:hidden;background-color:rgba(0,0,0,.75)}#atlt_strings_model .modal-content{position:relative;background-color:#fefefe;width:80%;height:calc(100% - 40px);margin:32px auto 0;overflow:hidden;border-radius:5px;box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);-webkit-animation-name:animatetop;-webkit-animation-duration:.4s;animation-name:animatetop;animation-duration:.4s}@-webkit-keyframes animatetop{from{top:-300px;opacity:0}to{top:0;opacity:1}}@keyframes animatetop{from{top:-300px;opacity:0}to{top:0;opacity:1}}#atlt_strings_model .modal-header{padding:2px 16px;background-color:#5cb85c;color:#fff;height:86px;max-height:86px;overflow:hidden;position:relative}#atlt_strings_model .modal-header h2{display:inline-block;font-size:18px;color:#000;padding:0;margin:18px 159px 5px 0;width:calc(100% - 160px)}#atlt_strings_model .modal-header .close{color:#fff;font-size:28px;font-weight:700;position:absolute;right:10px;top:20px}#atlt_strings_model .modal-header .close:focus,#atlt_strings_model .modal-header .close:hover{color:#000;text-decoration:none;cursor:pointer}#atlt_strings_model .save_btn_cont{margin:8px;position:absolute;top:10px;right:40px}#atlt_strings_model .ytstats{padding:0;margin:5px 160px 5px 0;width:calc(100% - 160px)}#atlt_strings_model .ytstats a{color:#fff936}#atlt_strings_model .modal-body{padding:2px 16px;position:relative}#atlt_strings_model .notice-dismiss{padding:0}#atlt_strings_model h3{width:100%;display:inline-block;font-size:20px;padding:0;margin:20px 0 0}#translate_element{margin-bottom:25px}#atlt_strings_model .string_container{overflow-y:scroll;overflow-x:hidden;height:calc(100vh - 460px);width:100%;position:relative}#atlt_strings_model table{border-spacing:0;border-collapse:collapse;width:100%;max-width:100%;table-layout:fixed;padding:0;margin:0}#atlt_strings_model table td:first-child,#atlt_strings_model table th:first-child{width:60px;text-align:center}#atlt_strings_model table td,#atlt_strings_model table th{border:1px solid #ddd;padding:4px;height:26px;text-align:left;white-space:nowrap;font-size:12px;line-height:14px;overflow:hidden;vertical-align:middle}#atlt_strings_model .my_translate_progress{position:absolute;display:none;top:0;left:10px;color:#fff;background:rgba(0,0,0,.5);width:calc(100% - 22px);border-radius:3px;height:100%;z-index:9;box-sizing:border-box;font-size:16px;line-height:20px;font-weight:700;text-align:center;padding-top:30px}#atlt_strings_model .modal-footer{padding:2px 16px;background-color:#5cb85c;color:#fff;position:absolute;width:calc(100% - 32px);bottom:0;height:66px;max-height:66px}.goog-te-banner-frame.skiptranslate{display:none!important}.goog-te-combo option:first-child{display:none}#yt-widget .yt-listbox__text{line-height:14px!important}#yt-widget .yt-listbox__input:not(:checked)~.yt-listbox__text{display:none!important}
1
+ #cool-auto-translate-btn:before{padding-right:5px!important}#cool-auto-translate-btn:after{content:"No API Required!";clear:both;display:block;font-size:10px;font-weight:700;font-family:monospace;position:absolute;bottom:-6px;left:-1px;background:#129412;width:calc(100% + 2px);height:12px;line-height:12px;color:#fff;text-align:center;border-radius:0 0 4px 4px}span.proonly-button{background:#555;color:#fff;font-size:12px;font-weight:700;font-family:monospace;padding:3px;border-radius:3px;display:inline-block;margin:2px 10px}span.proonly-button a{color:#fff;text-decoration:none}span.proonly-button.alsofree{background:green}span.proonly-button.alsofree img{filter:brightness(10);-webkit-filter:brightness(10)}#atlt_strings_model{display:none;position:fixed;z-index:99999;top:0;width:100%;height:100vh;overflow:hidden;background-color:rgba(0,0,0,.75)}#atlt_strings_model .modal-content{position:relative;background-color:#fefefe;width:80%;height:calc(100% - 40px);margin:32px auto 0;overflow:hidden;border-radius:5px;box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);-webkit-animation-name:animatetop;-webkit-animation-duration:.4s;animation-name:animatetop;animation-duration:.4s}@-webkit-keyframes animatetop{from{top:-300px;opacity:0}to{top:0;opacity:1}}@keyframes animatetop{from{top:-300px;opacity:0}to{top:0;opacity:1}}#atlt_strings_model .modal-header{padding:2px 16px;background-color:#5cb85c;color:#fff;height:86px;max-height:86px;overflow:hidden;position:relative}#atlt_strings_model .modal-header h2{display:inline-block;font-size:18px;color:#000;padding:0;margin:18px 159px 5px 0;width:calc(100% - 160px)}#atlt_strings_model .modal-header .close{color:#fff;font-size:28px;font-weight:700;position:absolute;right:10px;top:20px}#atlt_strings_model .modal-header .close:focus,#atlt_strings_model .modal-header .close:hover{color:#000;text-decoration:none;cursor:pointer}#atlt_strings_model .save_btn_cont{margin:8px;position:absolute;top:10px;right:40px}#atlt_strings_model .save_btn_cont button:not([disabled]):before{font-family:dashicons;content:"\f345";display:inline-block;font-size:24px;line-height:26px;vertical-align:middle;left:-20px;position:absolute;color:#fff;animation:moveit 5s infinite;-webkit-animation:moveit 1s infinite}@keyframes moveit{from{left:-22px}to{left:-10px}}#atlt_strings_model .ytstats{padding:0;margin:5px 160px 5px 0;width:calc(100% - 160px)}#atlt_strings_model .ytstats a{color:#fff936}#atlt_strings_model .modal-body{padding:2px 16px;position:relative}#atlt_strings_model .notice-dismiss{padding:0}#atlt_strings_model h3{width:100%;display:inline-block;font-size:22px;padding:0;margin:20px 0 10px;color:#5cb85c}#translate_element{margin-bottom:25px}#atlt_strings_model .string_container{overflow-y:scroll;overflow-x:hidden;height:calc(100vh - 460px);width:100%;position:relative}#atlt_strings_model table{border-spacing:0;border-collapse:collapse;width:100%;max-width:100%;table-layout:fixed;padding:0;margin:0}#atlt_strings_model table td:first-child,#atlt_strings_model table th:first-child{width:60px;text-align:center}#atlt_strings_model table td,#atlt_strings_model table th{border:1px solid #ddd;padding:4px;height:26px;text-align:left;white-space:nowrap;font-size:12px;line-height:14px;overflow:hidden;vertical-align:middle}#atlt_strings_model .my_translate_progress{position:absolute;display:none;top:0;left:10px;color:#fff;background:rgba(0,0,0,.5);width:calc(100% - 22px);border-radius:3px;height:100%;z-index:9;box-sizing:border-box;font-size:16px;line-height:20px;font-weight:700;text-align:center;padding-top:30px}#atlt_strings_model .modal-footer{padding:2px 16px;background-color:#5cb85c;color:#fff;position:absolute;width:calc(100% - 32px);bottom:0;height:66px;max-height:66px}.goog-te-banner-frame.skiptranslate{display:none!important}.goog-te-combo option:first-child{display:none}#yt-widget .yt-listbox__text{line-height:14px!important}#yt-widget .yt-listbox__input:not(:checked)~.yt-listbox__text{display:none!important}#loco-hint .loco-api.loco-api-loco_auto{display:none}html.merge-translations:before{position:fixed;width:100%;height:100%;background:rgb(0,0,0,.9);z-index:9999990;content:"Merging Translations.....";color:#fff;font-size:28px;text-align:center;padding-top:50px}.ui-dialog.loco-modal.ui-draggable.addtranslations{border:6px solid #5cb85c}
assets/images/coolplugins-logo.png ADDED
Binary file
assets/js/custom.js CHANGED
@@ -1,163 +1,542 @@
1
- /*
2
- It is master branch code
3
- */
4
-
5
- /*
6
- it is testing branch
7
- */
8
- !function( window, $ ){
9
- createSettingsPopup();
10
- createStringsPopup();
11
- //create_deepl_popup();
12
- //createSettingsPopup();
13
-
14
- /*
15
- String Translate Model
16
- */
17
- // Get the modal
18
- var gModal = document.getElementById("atlt_strings_model");
19
-
20
- // When the user clicks anywhere outside of the modal, close it
21
- window.onclick = function(event) {
22
- if (event.target == gModal) {
23
- gModal.style.display = "none";
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- // Get the <span> element that closes the modal
28
- $("#atlt_strings_model").find(".close").on("click",function() {
29
- $("#atlt_strings_model").fadeOut("slow");
30
- });
31
 
32
- // integrates auto traslator button in editor
33
- function newaddAutoTranslationBtn(){
34
- if($("#loco-toolbar").find("#cool-auto-translate-btn").length>0){
35
- $("#loco-toolbar").find("#cool-auto-translate-btn").remove();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
- const locoActions= $("#loco-toolbar").find("#loco-actions");
38
- const proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';
39
-
40
- locoActions.append(proActiveBtn);
41
-
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- // create auto translate settings popup
45
- function createSettingsPopup(){
46
- let preloaderImg=extradata['preloader_path'];
47
- let ytPreviewImg=extradata['yt_preview'];
48
- let gtPreviewImg=extradata['gt_preview'];
49
- let dplPreviewImg=extradata['dpl_preview'];
50
- let modelHTML=`
51
- <!-- The Modal -->
52
- <div id="atlt-dialog" title="Auto Translate (No API Required)" style="display:none;">
53
- <div class="atlt-settings">
54
-
55
- <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Yandex Page Translate Widget</strong>
56
- <div class="inputGroup">
57
- <button id="atlt_yandex_transate_btn" class="notranslate button button-primary">Yandex Translate</button>
58
- <span class="proonly-button alsofree">✔ Available</span>
59
- <br/><a href="https://translate.yandex.com/" target="_blank"><img style="margin-top: 5px;" src="${ytPreviewImg}" alt="powered by Yandex Translate Widget"></a>
60
- </div>
61
- <hr/>
62
-
63
- <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Widget</strong>
64
- <div class="inputGroup">
65
- <button id="atlt_gtranslate_btn" disabled="disabled" class="notranslate button button-primary">Google Translate</button>
66
- <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>
67
- <br/><a href="https://translate.google.com/" target="_blank"><img style="margin-top: 5px;" src="${gtPreviewImg}" alt="powered by Google Translate Widget"></a>
68
- </div>
69
- <hr/>
70
-
71
- <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Deepl Doc Translator</strong>
72
- <div class="inputGroup">
73
- <button disabled="disabled" id="atlt_deepl_btn" class="notranslate button button-primary">DeepL Translate</button>
74
- <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>
75
- <br/><a href="https://www.deepl.com/en/translator" target="_blank"><img style="margin-top: 5px;" src="${dplPreviewImg}" alt="powered by DeepL Translate"></a>
76
- <br/>DeepL translation is beeter than Google, Microsoft & other auto-translation providers - <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank">read review by techcruch</a>
77
- </div>
78
- <hr/>
79
-
80
- <ul style="margin: 0;">
81
- <li><span style="color:green">✔</span> Unlimited Translations</li>
82
- <li><span style="color:green">✔</span> No API Key Required</li>
83
- <li><span style="color:green">✔</span> Check Languages Support - <a href="https://yandex.com/support/translate/supported-langs.html" target="_blank">Yandex</a>, <a href="https://en.wikipedia.org/wiki/Google_Translate#Supported_languages" target="_blank">Google</a>, <a href="https://www.deepl.com/en/translator" target="_blank">DeepL</a></li>
84
- </ul>
85
-
86
- </div>
87
- </div>
88
- `;
89
- $("body").append( modelHTML );
90
- }
91
 
92
- /**
93
- * generate model popup HTML
94
- */
95
- function createStringsPopup(){
96
- let modelHTML=`
97
- <!-- The Modal -->
98
- <div id="atlt_strings_model" class="modal atlt_custom_model">
99
- <!-- Modal content -->
100
- <div class="modal-content">
101
- <div class="modal-header">
102
- <span class="close ">&times;</span>
103
- <h2 class="notranslate">Automatic Translations </h2>
104
- <div class="save_btn_cont">
105
- <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>
106
- </div>
107
 
108
- <div style="display:none" class="ytstats">
109
- Wahooo! You have saved your valauble time via auto translating
110
- <strong class="totalChars"> </strong> characters using
111
- <strong>
112
- <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">
113
- Loco Automatic Translate Addon</a>
114
- </strong>
115
- </div>
116
 
117
- </div>
118
- <div class="notice inline notice-info is-dismissible">Plugin will not translate any strings with HTML or special characters because Yandex Translator currently
119
- does not support HTML and special characters translations.
120
- You can edit translated strings inside Loco Translate Editor after merging the translations. Only special chracters (%s, %d) fixed at the time of merging of the translations.</div>
121
- <div class="notice inline notice-info is-dismissible">Machine translations are not 100% correct.
122
- Please verify strings before using on production website.</div>
123
- <div class="modal-body">
124
- <div class="my_translate_progress">Automatic translation is in progress....<br/>It will take few minutes, enjoy ☕ coffee in this time!</div>
125
- <h3>Choose language</h3>
126
- <div id="ytWidget">..Loading</div>
127
- <br/>
128
- <div class="string_container">
129
- <table class="scrolldown" id="stringTemplate">
130
- <thead>
131
- <th class="notranslate">S.No</th>
132
- <th class="notranslate">Source Text</th>
133
- <th class="notranslate">Translation</th>
134
- </thead>
135
- <tbody id="yandex_string_tbl">
136
- </tbody>
137
- </table>
138
- </div>
139
- </div>
140
- <div class="modal-footer">
141
- <div class="save_btn_cont">
142
- <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  </div>
144
- <div style="display:none" class="ytstats">
145
- Wahooo! You have saved your valauble time via auto translating
146
- <strong class="totalChars"></strong> characters using
147
- <strong>
148
- <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">
149
- Loco Automatic Translate Addon</a>
150
- </strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  </div>
152
- </div>
 
 
 
 
 
 
 
 
 
 
 
153
  </div>
154
- </div>`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
 
156
- $("body").append( modelHTML );
157
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
 
 
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
- }( window, jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ It is master branch code
3
+ */
4
+ ! function(window, $) {
5
+
6
+ if (window.locoConf != undefined) {
7
+ var locoConf = window.locoConf;
8
+ if (locoConf.conf != undefined) {
9
+ var allStrings = locoConf.conf.podata;
10
+ allStrings.shift();
11
+ var ajaxUrl = extradata.ajax_url;
12
+ var nonces = extradata.nonce;
13
+ var locale = locoConf.conf.locale;
14
+ var projectId = '';
15
+ if (locoConf.conf.project != null) {
16
+ projectId = locoConf.conf.project.domain + '-' + locale.lang + '_' + locale.region;
17
+ } else {
18
+ projectId = 'temp-' + locale.lang + '_' + locale.region;
19
+ }
20
+ /*
21
+ since version 1.1
22
+ Google Translate Popup handlers
23
+ */
24
+ newaddAutoTranslationBtn();
25
+
26
+ settingsModel();
27
+ createStringsPopup();
28
+ }
29
+ }
30
+
31
+ // integrates auto traslator button in editor
32
+ function newaddAutoTranslationBtn() {
33
+ if ($("#loco-toolbar").find("#cool-auto-translate-btn").length > 0) {
34
+ $("#loco-toolbar").find("#cool-auto-translate-btn").remove();
35
+ }
36
+ const locoActions = $("#loco-toolbar").find("#loco-actions");
37
+ const proActiveBtn = '<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';
38
+ locoActions.append(proActiveBtn);
39
+ }
40
 
 
 
 
 
41
 
42
+ // open popup on autotranslate button click
43
+ $("#cool-auto-translate-btn").on("click", function() {
44
+ createPopup();
45
+ });
46
+ // create auto translate popup
47
+ function createPopup() {
48
+ $("#atlt-dialog").dialog({
49
+ resizable: false,
50
+ height: "auto",
51
+ width: 400,
52
+ modal: true,
53
+ buttons: {
54
+ Cancel: function() {
55
+ $(this).dialog("close");
56
+ }
57
+ }
58
+ });
59
+ }
60
+
61
+
62
+ // Get the button that opens the modal
63
+ // var gTranslateBtn = document.getElementById("atlt_gtranslate_btn");
64
+
65
+ var encodeHtmlEntity = function(str) {
66
+ var buf = [];
67
+ for (var i=str.length-1;i>=0;i--) {
68
+ buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
69
  }
70
+ return buf.join('');
71
+ };
72
+ /*
73
+ load strings in popup table
74
+ */
75
+ function printStringsInPopup(jsonObj, type) {
76
+ var html = '';
77
+ var totalTChars = 0;
78
+ var index = 1;
79
+ if (jsonObj) {
80
+ for (const key in jsonObj) {
81
+ if (jsonObj.hasOwnProperty(key)) {
82
+ const element = jsonObj[key];
83
+ if (element.source != '') {
84
+ if (type == "yandex") {
85
+ html += '<tr id="' + key + '" ><td>' + index + '</td><td class="notranslate source" >' + encodeHtmlEntity(element.source) +'</td>';
86
+ } else {
87
+ if (key > 2500) {
88
+ break;
89
+ }
90
+ html += '<tr id="' + key + '" ><td>' + index + '</td><td class="notranslate source">' + element.source + '</td>';
91
+ }
92
+ if (type == "yandex") {
93
+ html += '<td translate="yes" class="target translate">' + element.source + '</td></tr>';
94
+ } else {
95
+ html += '<td class="target translate"></td></tr>';
96
+ }
97
+ index++;
98
+ totalTChars += element.source.length;
99
+ }
100
+ }
101
+ }
102
+ $(".ytstats").each(function() {
103
+ $(this).find(".totalChars").html(totalTChars);
104
+ });
105
+ }
106
+ if (type == "yandex") {
107
+ $("#yandex_string_tbl").html(html);
108
+ }
109
+ }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
+ /*
113
+ String Translate Model
114
+ */
115
+ // Get the modal
116
+ var gModal = document.getElementById("atlt_strings_model");
 
 
 
 
 
 
 
 
 
 
117
 
118
+ // When the user clicks anywhere outside of the modal, close it
119
+ window.onclick = function(event) {
120
+ if (event.target == gModal) {
121
+ gModal.style.display = "none";
122
+ }
123
+ }
 
 
124
 
125
+ // Get the <span> element that closes the modal
126
+ $("#atlt_strings_model").find(".close").on("click", function() {
127
+ $("#atlt_strings_model").fadeOut("slow");
128
+ });
129
+
130
+
131
+ // create auto translate settings popup
132
+ function settingsModel() {
133
+ let ytPreviewImg = extradata['yt_preview'];
134
+ let gtPreviewImg = extradata['gt_preview'];
135
+ let dplPreviewImg = extradata['dpl_preview'];
136
+ let modelHTML = `
137
+ <!-- The Modal -->
138
+ <div id="atlt-dialog" title="Step 1 - Select Translation Provider" style="display:none;">
139
+ <div class="atlt-settings">
140
+
141
+ <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Yandex Page Translate Widget</strong>
142
+ <div class="inputGroup">
143
+ <button id="atlt_yandex_transate_btn" class="notranslate button button-primary">Yandex Translate</button>
144
+ <span class="proonly-button alsofree">✔ Available</span>
145
+ <br/><a href="https://translate.yandex.com/" target="_blank"><img style="margin-top: 5px;" src="${ytPreviewImg}" alt="powered by Yandex Translate Widget"></a>
146
+ </div>
147
+ <hr/>
148
+
149
+ <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Widget</strong>
150
+ <div class="inputGroup">
151
+ <button id="atlt_gtranslate_btn" disabled="disabled" class="notranslate button button-primary">Google Translate</button>
152
+ <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>
153
+ <br/><a href="https://translate.google.com/" target="_blank"><img style="margin-top: 5px;" src="${gtPreviewImg}" alt="powered by Google Translate Widget"></a>
154
+ </div>
155
+ <hr/>
156
+
157
+ <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Deepl Doc Translator</strong>
158
+ <div class="inputGroup">
159
+ <button disabled="disabled" id="atlt_deepl_btn" class="notranslate button button-primary">DeepL Translate</button>
160
+ <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>
161
+ <br/><a href="https://www.deepl.com/en/translator" target="_blank"><img style="margin-top: 5px;" src="${dplPreviewImg}" alt="powered by DeepL Translate"></a>
162
+ <br/>DeepL translation is better than Google, Microsoft & other auto-translation providers - <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank">read review by techcruch</a>
163
+ </div>
164
+ <hr/>
165
+
166
+ <ul style="margin: 0;">
167
+ <li><span style="color:green">✔</span> Unlimited Translations<br/>(<span style="font-size: 11px;color: #248e09;">*DeepL provides limited no. of free doc translations daily</span>)</li>
168
+ <li><span style="color:green">✔</span> No API Key Required</li>
169
+ <li><span style="color:green">✔</span> Check Languages Support - <a href="https://yandex.com/support/translate/supported-langs.html" target="_blank">Yandex</a>, <a href="https://en.wikipedia.org/wiki/Google_Translate#Supported_languages" target="_blank">Google</a>, <a href="https://www.deepl.com/en/translator" target="_blank">DeepL</a></li>
170
+ </ul>
171
+
172
+ </div>
173
+ </div>
174
+ `;
175
+ $("body").append(modelHTML);
176
+ }
177
+
178
+ /**
179
+ * generate model popup HTML
180
+ */
181
+ function createStringsPopup() {
182
+ let modelHTML = `
183
+ <!-- The Modal -->
184
+ <div id="atlt_strings_model" class="modal atlt_custom_model">
185
+ <!-- Modal content -->
186
+ <div class="modal-content">
187
+ <input type="hidden" id="project_id" value="${projectId}">
188
+ <div class="modal-header">
189
+ <span class="close ">&times;</span>
190
+ <h2 class="notranslate">Step 2 - Start Automatic Translation Process</h2>
191
+ <div class="save_btn_cont">
192
+ <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>
193
+ </div>
194
+
195
+ <div style="display:none" class="ytstats hidden">
196
+ Wahooo! You have saved your valauble time via auto translating
197
+ <strong class="totalChars"> </strong> characters using
198
+ <strong>
199
+ <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">
200
+ Loco Automatic Translate Addon</a>
201
+ </strong>
202
+ </div>
203
+
204
  </div>
205
+ <div class="notice inline notice-info is-dismissible">Plugin will not translate any strings with HTML or special characters because Yandex Translator currently
206
+ does not support HTML and special characters translations.
207
+ You can edit translated strings inside Loco Translate Editor after merging the translations. Only special chracters (%s, %d) fixed at the time of merging of the translations.</div>
208
+ <div class="notice inline notice-info is-dismissible">Machine translations are not 100% correct.
209
+ Please verify strings before using on production website.</div>
210
+ <div class="modal-body">
211
+ <div class="my_translate_progress">Automatic translation is in progress....<br/>It will take few minutes, enjoy ☕ coffee in this time!<br/><br/>Please do not leave this window or browser tab while translation is in progress...</div>
212
+ <h3 class="choose-lang">Choose language <span class="dashicons-before dashicons-translation"></span></h3>
213
+ <div id="ytWidget">..Loading</div>
214
+ <br/>
215
+ <div class="string_container">
216
+ <table class="scrolldown" id="stringTemplate">
217
+ <thead>
218
+ <th class="notranslate">S.No</th>
219
+ <th class="notranslate">Source Text</th>
220
+ <th class="notranslate">Translation</th>
221
+ </thead>
222
+ <tbody id="yandex_string_tbl">
223
+ </tbody>
224
+ </table>
225
+ </div>
226
+ <div class="notice-container"></div>
227
  </div>
228
+ <div class="modal-footer">
229
+ <div class="save_btn_cont">
230
+ <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>
231
+ </div>
232
+ <div style="display:none" class="ytstats">
233
+ Wahooo! You have saved your valauble time via auto translating
234
+ <strong class="totalChars"></strong> characters using
235
+ <strong>
236
+ <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">
237
+ Loco Automatic Translate Addon</a>
238
+ </strong>
239
+ </div>
240
  </div>
241
+ </div>
242
+ </div>`;
243
+
244
+ $("body").append(modelHTML);
245
+ }
246
+
247
+
248
+
249
+ // When the user clicks the button, open the modal
250
+ $("#atlt_yandex_transate_btn").on("click", function() {
251
+
252
+ var defaultcode = locale.lang ? locale.lang : null;
253
+
254
+ switch (defaultcode) {
255
+ case 'bel':
256
+ defaultlang = 'be';
257
+ break;
258
+ case 'he':
259
+ defaultlang = 'iw';
260
+ break;
261
+ case 'snd':
262
+ defaultlang = 'sd';
263
+ break;
264
+ case 'jv':
265
+ defaultlang = 'jv';
266
+ break;
267
+ case 'nb':
268
+ defaultlang = 'no';
269
+ break;
270
+
271
+ case 'nn':
272
+ defaultlang = 'no';
273
+ break;
274
+ default:
275
+ defaultlang = defaultcode;
276
+ break;
277
+ }
278
+
279
+ $(".save_it").prop("disabled", true);
280
+ $(".ytstats").css("display", "none");
281
+ localStorage.setItem("lang", defaultlang);
282
+ var arr = ['af', 'jv', 'no', 'am', 'ar', 'az', 'ba', 'be', 'bg', 'bn', 'bs', 'ca', 'ceb', 'cs', 'cy', 'da', 'de', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fr', 'ga', 'gd', 'gl', 'gu', 'he', 'hi', 'hr', 'ht', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'jv', 'ka', 'kk', 'km', 'kn', 'ko', 'ky', 'la', 'lb', 'lo', 'lt', 'lv', 'mg', 'mhr', 'mi', 'mk', 'ml', 'mn', 'mr', 'mrj', 'ms', 'mt', 'my', 'ne', 'nl', 'no', 'pa', 'pap', 'pl', 'pt', 'ro', 'ru', 'si', 'sk', 'sl', 'sq', 'sr', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'tl', 'tr', 'tt', 'udm', 'uk', 'ur', 'uz', 'vi', 'xh', 'yi', 'zh'];
283
+ if (arr.includes(defaultlang)) {
284
+ // googleTranslateElementInit();
285
+ } else {
286
+ $(".notice-container").addClass('notice inline notice-warning')
287
+ .html("Yandex Automatic Translator Does not support this language.");
288
+ $(".string_container").hide();
289
+ $(".choose-lang").hide();
290
+ $(".save_it").hide();
291
+ $("#ytWidget").hide();
292
+ }
293
+ // get only plain strings
294
+ var plainStrArr = filterRawObject(allStrings, "plain");
295
+ if (plainStrArr.length > 0) {
296
+ printStringsInPopup(plainStrArr, type = "yandex");
297
+ } else {
298
+ $("#ytWidget").hide();
299
+ $(".notice-container").addClass('notice inline notice-warning')
300
+ .html("There is no plain string available for translations.");
301
+ $(".string_container").hide();
302
+ $(".choose-lang").hide();
303
+ $(".save_it").hide();
304
+ }
305
+ $("#atlt-dialog").dialog("close");
306
+ $("#atlt_strings_model").addClass("yandex-translator").fadeIn("slow");
307
+
308
+ });
309
+
310
+ function saveTranslatedStrings(translatedObj, projectId) {
311
 
312
+ if (translatedObj !== undefined && translatedObj.length) {
313
+
314
+ if (translatedObj.length < 5000 && translatedObj.length >= 2500) {
315
+ var firstPart = translatedObj.slice(0, 2500);
316
+ var secondPart = translatedObj.slice(2500);
317
+ sendRequest(firstPart, projectId, part = "first");
318
+ sendRequest(secondPart, projectId, part = "second", );
319
+ } else if (translatedObj.length >= 5000) {
320
+ var firstPart = translatedObj.slice(0, 2500);
321
+ var secondPart = translatedObj.slice(2500, 5000);
322
+ var thirdpart = translatedObj.slice(5000);
323
+ sendRequest(firstPart, projectId, part = "first");
324
+ sendRequest(secondPart, projectId, part = "second", );
325
+ sendRequest(thirdpart, projectId, part = "third", );
326
+ } else {
327
+ sendRequest(translatedObj, projectId, part = "one");
328
+ }
329
+
330
 
331
+ }
332
+ }
333
 
334
+ function sendRequest(stringData, projectId, part) {
335
+ var data = {
336
+ 'action': 'save_translations',
337
+ 'data': JSON.stringify(stringData),
338
+ 'part': part,
339
+ 'project-id': projectId,
340
+ };
341
+ jQuery.post(ajaxUrl, data, function(response) {
342
+
343
+ $('#loco-toolbar').find('button').each(function(i, el) {
344
+ var id = el.getAttribute('data-loco');
345
+ if (id == "auto") {
346
+ $(el).trigger("click");
347
+ }
348
+ });
349
+ });
350
 
351
 
352
+ }
353
+ /*
354
+ Save Translated Strings
355
+ */
356
+ var rpl = {
357
+ '"% s"': '"%s"',
358
+ '"% d"': '"%d"',
359
+ '"% S"': '"%s"',
360
+ '"% D"': '"%d"',
361
+ '% s': ' %s ',
362
+ '% S': ' %s ',
363
+ '% d': ' %d ',
364
+ '% D': ' %d ',
365
+ '٪ s': ' %s ',
366
+ '٪ S': ' %s ',
367
+ '٪ d': ' %d ',
368
+ '٪ D': ' %d ',
369
+ '٪ س': ' %s ',
370
+ };
371
+
372
 
373
+ //Click to merge translations
374
+ $(".save_it").on("click", function() {
375
+ var translatedObj = [];
376
+ $("#stringTemplate tbody tr").each(function(index) {
377
+ var index = $(this).find("td.source").text();
378
+ var target = $(this).find("td.target").text();
379
+ var source = $(this).find("td.source").text();
380
+ var improvedTarget= strtr(target,rpl) ;
381
+ var improvedSource= strtr(source,rpl) ;
382
+ translatedObj.push({
383
+ "source": improvedSource,
384
+ "target": improvedTarget
385
+ });
386
+ });
387
+ var projectId = $(this).parents("#atlt_strings_model").find("#project_id").val();
388
+ saveTranslatedStrings(translatedObj, projectId);
389
+ var translatedObj = [];
390
+ $(".atlt_custom_model").fadeOut("slow");
391
+
392
+ $("html").addClass("merge-translations");
393
+ var checkModal = setInterval(function() {
394
+ if ($('.loco-modal').length && String($(".loco-modal").attr("style")).indexOf("block") > -1) {
395
+ $("html").removeClass("merge-translations");
396
+ $("select#auto-api").hide();
397
+ $("#loco-auto a.icon-help").hide();
398
+ $("#loco-auto #loco-job-progress").hide();
399
+ $("select#auto-api option[value='loco_auto']").prop("selected", "selected");
400
+ //$("select#auto-api option[value='loco_auto']").attr("selected", "selected");
401
+ $("select#auto-api").val($("select#auto-api option[value='loco_auto']").val());
402
+ $(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Step 3 - Add Translations into Editor and Save");
403
+ $("#loco-auto button.button-primary span").html("Start Adding Process");
404
+
405
+ $("#loco-auto button.button-primary").on("click",function(){
406
+ $(this).find('span').html("Adding...");
407
+ });
408
+
409
+ $(".loco-modal").addClass("addtranslations");
410
+ $('.noapiadded').remove();
411
+ $(".loco-modal #loco-auto form").show();
412
+ $(".loco-modal #loco-auto").removeClass("loco-alert");
413
+ clearInterval(checkModal);
414
+ }
415
+ }, 100); // check every 100ms
416
+ });
417
+
418
+ //Click on Loco Default Auto Button
419
+ $("button.icon-robot[data-loco='auto']").on("click", function(e) {
420
+ if (e.originalEvent !== undefined) {
421
+ $(".loco-modal").removeClass("addtranslations");
422
+ $("select#auto-api").show();
423
+ $("#loco-auto a.icon-help").show();
424
+ $("#loco-auto #loco-job-progress").show();
425
+ $(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Auto-translate this file");
426
+ $("#loco-auto button.button-primary span").html("Translate");
427
+ var opt = 0;
428
+ setTimeout(function() {
429
+ $('select#auto-api option').each(function() {
430
+ opt = opt + 1;
431
+ });
432
+ if (opt == 1) {
433
+ $('.noapiadded').remove();
434
+ $(".loco-modal #loco-auto").removeClass("loco-alert");
435
+ $(".loco-modal #loco-auto form").hide();
436
+ $(".loco-modal #loco-auto").addClass("loco-alert");
437
+ $(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("No translation APIs configured");
438
+ $(".loco-modal #loco-auto").append("<div class='noapiadded'><p>Add automatic translation services in the plugin settings.<br>or<br>Use <strong>Auto Translate</strong> addon button.</p><nav><a href='http://locotranslate.local/wp-admin/admin.php?page=loco-config&amp;action=apis' class='has-icon icon-cog'>Settings</a><a href='https://localise.biz/wordpress/plugin/manual/providers?utm_medium=plugin&amp;utm_campaign=wp&amp;utm_source=admin&amp;utm_content=plugin-file-edit' class='has-icon icon-help' target='_blank'>Help</a></nav></div>");
439
+ } else {
440
+ //$("select#auto-api option:nth-child(2)").prop("selected", "selected");
441
+ //$("select#auto-api").val($("select#auto-api option:nth-child(2)").val());
442
+ }
443
+ }, 400);
444
+ }
445
+ });
446
+
447
+ // filter string based upon type
448
+ function filterRawObject(rawArray, filterType) {
449
+ filterdArr = [];
450
+ return filterdArr = rawArray.filter((item, index) => {
451
+ if ((item.source !== "" && item.source !== undefined) && (item.target === undefined || item.target == "")) {
452
+ if (ValidURL(item.source)) {
453
+ return false;
454
+ }
455
+ if (isHTML(item.source)) {
456
+ return false;
457
+ } else if (isPlacehodersChars(item.source)) {
458
+ return true;
459
+ } else if (isSpecialChars(item.source)) {
460
+ return false;
461
+ }else if (isEmoji(item.source)) {
462
+ return false;
463
+ }
464
+ else if (item.source.includes('#')) {
465
+ return false;
466
+ } else {
467
+ return true;
468
+ }
469
+ }
470
+ });
471
+ }
472
+
473
+
474
+ // detect String contain URL
475
+ function ValidURL(str) {
476
+ var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
477
+ if (!pattern.test(str)) {
478
+ return false;
479
+ } else {
480
+ return true;
481
+ }
482
+ }
483
+ // detect Valid HTML in string
484
+ function isHTML(str) {
485
+ var rgex = /<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i;
486
+ if (str !== undefined) {
487
+ return rgex.test(str);
488
+ } else {
489
+ return false;
490
+ }
491
+ }
492
+ // check special chars in string
493
+ function isSpecialChars(str) {
494
+ var rgex = /[@^{}|<>]/g;
495
+ if (str !== undefined) {
496
+ return rgex.test(str);
497
+ } else {
498
+ return false;
499
+ }
500
+ }
501
+ function isEmoji(str) {
502
+ var ranges = [
503
+ '(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])' // U+1F680 to U+1F6FF
504
+ ];
505
+ if (str.match(ranges.join('|'))) {
506
+ return true;
507
+ } else {
508
+ return false;
509
+ }
510
+ }
511
+
512
+ // allowed special chars in plain text
513
+ function isPlacehodersChars(str) {
514
+ var rgex = /%s|%d/g;
515
+ if (str !== undefined) {
516
+ return rgex.test(str);
517
+ } else {
518
+ return false;
519
+ }
520
+ }
521
+
522
+
523
+ // replace placeholders in strings
524
+ function strtr(s, p, r) {
525
+ return !!s && {
526
+ 2: function () {
527
+ for (var i in p) {
528
+ s = strtr(s, i, p[i]);
529
+ }
530
+ return s;
531
+ },
532
+ 3: function () {
533
+ return s.replace(RegExp(p, 'g'), r);
534
+ },
535
+ 0: function () {
536
+ return;
537
+ }
538
+ }[arguments.length]();
539
+ }
540
+
541
+
542
+ }(window, jQuery);
assets/js/custom.min.js CHANGED
@@ -1 +1 @@
1
- !function(window,$){createSettingsPopup(),createStringsPopup();var gModal=document.getElementById("atlt_strings_model");function newaddAutoTranslationBtn(){$("#loco-toolbar").find("#cool-auto-translate-btn").length>0&&$("#loco-toolbar").find("#cool-auto-translate-btn").remove();const locoActions=$("#loco-toolbar").find("#loco-actions"),proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(proActiveBtn)}function createSettingsPopup(){let preloaderImg=extradata.preloader_path,ytPreviewImg,gtPreviewImg,dplPreviewImg,modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt-dialog" title="Auto Translate (No API Required)" style="display:none;">\n <div class="atlt-settings">\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Yandex Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_yandex_transate_btn" class="notranslate button button-primary">Yandex Translate</button>\n <span class="proonly-button alsofree">✔ Available</span>\n <br/><a href="https://translate.yandex.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.yt_preview}" alt="powered by Yandex Translate Widget"></a>\n </div>\n <hr/>\n\n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_gtranslate_btn" disabled="disabled" class="notranslate button button-primary">Google Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://translate.google.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.gt_preview}" alt="powered by Google Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Deepl Doc Translator</strong>\n <div class="inputGroup">\n <button disabled="disabled" id="atlt_deepl_btn" class="notranslate button button-primary">DeepL Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://www.deepl.com/en/translator" target="_blank"><img style="margin-top: 5px;" src="${extradata.dpl_preview}" alt="powered by DeepL Translate"></a>\n <br/>DeepL translation is beeter than Google, Microsoft & other auto-translation providers - <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank">read review by techcruch</a>\n </div>\n <hr/>\n\n <ul style="margin: 0;">\n <li><span style="color:green">✔</span> Unlimited Translations</li>\n <li><span style="color:green">✔</span> No API Key Required</li>\n <li><span style="color:green">✔</span> Check Languages Support - <a href="https://yandex.com/support/translate/supported-langs.html" target="_blank">Yandex</a>, <a href="https://en.wikipedia.org/wiki/Google_Translate#Supported_languages" target="_blank">Google</a>, <a href="https://www.deepl.com/en/translator" target="_blank">DeepL</a></li>\n </ul>\n\n </div>\n </div>\n `;$("body").append(modelHTML)}function createStringsPopup(){let modelHTML=' \n \x3c!-- The Modal --\x3e\n <div id="atlt_strings_model" class="modal atlt_custom_model">\n \x3c!-- Modal content --\x3e\n <div class="modal-content">\n <div class="modal-header">\n <span class="close ">&times;</span>\n <h2 class="notranslate">Automatic Translations </h2>\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n\n <div style="display:none" class="ytstats">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"> </strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n\n </div>\n <div class="notice inline notice-info is-dismissible">Plugin will not translate any strings with HTML or special characters because Yandex Translator currently\n does not support HTML and special characters translations. \n You can edit translated strings inside Loco Translate Editor after merging the translations. Only special chracters (%s, %d) fixed at the time of merging of the translations.</div>\n <div class="notice inline notice-info is-dismissible">Machine translations are not 100% correct.\n Please verify strings before using on production website.</div>\n <div class="modal-body">\n <div class="my_translate_progress">Automatic translation is in progress....<br/>It will take few minutes, enjoy ☕ coffee in this time!</div>\n <h3>Choose language</h3>\n <div id="ytWidget">..Loading</div>\n <br/>\n <div class="string_container"> \n <table class="scrolldown" id="stringTemplate">\n <thead>\n <th class="notranslate">S.No</th>\n <th class="notranslate">Source Text</th>\n <th class="notranslate">Translation</th>\n </thead>\n <tbody id="yandex_string_tbl">\n </tbody>\n </table>\n </div>\n </div>\n <div class="modal-footer">\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n <div style="display:none" class="ytstats">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"></strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n </div>\n </div>\n </div>';$("body").append(modelHTML)}window.onclick=function(event){event.target==gModal&&(gModal.style.display="none")},$("#atlt_strings_model").find(".close").on("click",(function(){$("#atlt_strings_model").fadeOut("slow")}))}(window,jQuery);
1
+ !function(window,$){if(null!=window.locoConf){var locoConf=window.locoConf;if(null!=locoConf.conf){var allStrings=locoConf.conf.podata;allStrings.shift();var ajaxUrl=extradata.ajax_url,nonces=extradata.nonce,locale=locoConf.conf.locale,projectId="";projectId=null!=locoConf.conf.project?locoConf.conf.project.domain+"-"+locale.lang+"_"+locale.region:"temp-"+locale.lang+"_"+locale.region,newaddAutoTranslationBtn(),settingsModel(),createStringsPopup()}}function newaddAutoTranslationBtn(){$("#loco-toolbar").find("#cool-auto-translate-btn").length>0&&$("#loco-toolbar").find("#cool-auto-translate-btn").remove();const locoActions=$("#loco-toolbar").find("#loco-actions"),proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(proActiveBtn)}function createPopup(){$("#atlt-dialog").dialog({resizable:!1,height:"auto",width:400,modal:!0,buttons:{Cancel:function(){$(this).dialog("close")}}})}$("#cool-auto-translate-btn").on("click",(function(){createPopup()}));var encodeHtmlEntity=function(str){for(var buf=[],i=str.length-1;i>=0;i--)buf.unshift(["&#",str[i].charCodeAt(),";"].join(""));return buf.join("")};function printStringsInPopup(jsonObj,type){var html="",totalTChars=0,index=1;if(jsonObj){for(const key in jsonObj)if(jsonObj.hasOwnProperty(key)){const element=jsonObj[key];if(""!=element.source){if("yandex"==type)html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source" >'+encodeHtmlEntity(element.source)+"</td>";else{if(key>2500)break;html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+"</td>"}html+="yandex"==type?'<td translate="yes" class="target translate">'+element.source+"</td></tr>":'<td class="target translate"></td></tr>',index++,totalTChars+=element.source.length}}$(".ytstats").each((function(){$(this).find(".totalChars").html(totalTChars)}))}"yandex"==type&&$("#yandex_string_tbl").html(html)}var gModal=document.getElementById("atlt_strings_model");function settingsModel(){let ytPreviewImg,gtPreviewImg,dplPreviewImg,modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt-dialog" title="Step 1 - Select Translation Provider" style="display:none;">\n <div class="atlt-settings">\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Yandex Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_yandex_transate_btn" class="notranslate button button-primary">Yandex Translate</button>\n <span class="proonly-button alsofree">✔ Available</span>\n <br/><a href="https://translate.yandex.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.yt_preview}" alt="powered by Yandex Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Google Page Translate Widget</strong>\n <div class="inputGroup">\n <button id="atlt_gtranslate_btn" disabled="disabled" class="notranslate button button-primary">Google Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://translate.google.com/" target="_blank"><img style="margin-top: 5px;" src="${extradata.gt_preview}" alt="powered by Google Translate Widget"></a>\n </div>\n <hr/>\n \n <strong class="atlt-heading" style="margin-bottom:10px;display:inline-block;">Translate Using Deepl Doc Translator</strong>\n <div class="inputGroup">\n <button disabled="disabled" id="atlt_deepl_btn" class="notranslate button button-primary">DeepL Translate</button>\n <span class="proonly-button"><a href="https://bit.ly/locoaddon" target="_blank" title="Buy Pro">PRO Only</a></span>\n <br/><a href="https://www.deepl.com/en/translator" target="_blank"><img style="margin-top: 5px;" src="${extradata.dpl_preview}" alt="powered by DeepL Translate"></a>\n <br/>DeepL translation is better than Google, Microsoft & other auto-translation providers - <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank">read review by techcruch</a>\n </div>\n <hr/>\n \n <ul style="margin: 0;">\n <li><span style="color:green">✔</span> Unlimited Translations<br/>(<span style="font-size: 11px;color: #248e09;">*DeepL provides limited no. of free doc translations daily</span>)</li>\n <li><span style="color:green">✔</span> No API Key Required</li>\n <li><span style="color:green">✔</span> Check Languages Support - <a href="https://yandex.com/support/translate/supported-langs.html" target="_blank">Yandex</a>, <a href="https://en.wikipedia.org/wiki/Google_Translate#Supported_languages" target="_blank">Google</a>, <a href="https://www.deepl.com/en/translator" target="_blank">DeepL</a></li>\n </ul>\n \n </div>\n </div>\n `;$("body").append(modelHTML)}function createStringsPopup(){let modelHTML=` \n \x3c!-- The Modal --\x3e\n <div id="atlt_strings_model" class="modal atlt_custom_model">\n \x3c!-- Modal content --\x3e\n <div class="modal-content">\n <input type="hidden" id="project_id" value="${projectId}">\n <div class="modal-header">\n <span class="close ">&times;</span>\n <h2 class="notranslate">Step 2 - Start Automatic Translation Process</h2>\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n \n <div style="display:none" class="ytstats hidden">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"> </strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n \n </div>\n <div class="notice inline notice-info is-dismissible">Plugin will not translate any strings with HTML or special characters because Yandex Translator currently\n does not support HTML and special characters translations. \n You can edit translated strings inside Loco Translate Editor after merging the translations. Only special chracters (%s, %d) fixed at the time of merging of the translations.</div>\n <div class="notice inline notice-info is-dismissible">Machine translations are not 100% correct.\n Please verify strings before using on production website.</div>\n <div class="modal-body">\n <div class="my_translate_progress">Automatic translation is in progress....<br/>It will take few minutes, enjoy ☕ coffee in this time!<br/><br/>Please do not leave this window or browser tab while translation is in progress...</div>\n <h3 class="choose-lang">Choose language <span class="dashicons-before dashicons-translation"></span></h3>\n <div id="ytWidget">..Loading</div>\n <br/>\n <div class="string_container"> \n <table class="scrolldown" id="stringTemplate">\n <thead>\n <th class="notranslate">S.No</th>\n <th class="notranslate">Source Text</th>\n <th class="notranslate">Translation</th>\n </thead>\n <tbody id="yandex_string_tbl">\n </tbody>\n </table>\n </div>\n <div class="notice-container"></div>\n </div>\n <div class="modal-footer">\n <div class="save_btn_cont">\n <button class="notranslate save_it button button-primary" disabled="true">Merge Translation</button>\n </div>\n <div style="display:none" class="ytstats">\n Wahooo! You have saved your valauble time via auto translating \n <strong class="totalChars"></strong> characters using \n <strong> \n <a href="https://wordpress.org/support/plugin/automatic-translator-addon-for-loco-translate/reviews/#new-post" target="_new">\n Loco Automatic Translate Addon</a>\n </strong> \n </div>\n </div>\n </div>\n </div>`;$("body").append(modelHTML)}function saveTranslatedStrings(translatedObj,projectId){if(void 0!==translatedObj&&translatedObj.length)if(translatedObj.length<5e3&&translatedObj.length>=2500){var firstPart=translatedObj.slice(0,2500),secondPart=translatedObj.slice(2500);sendRequest(firstPart,projectId,part="first"),sendRequest(secondPart,projectId,part="second")}else if(translatedObj.length>=5e3){var firstPart=translatedObj.slice(0,2500),secondPart=translatedObj.slice(2500,5e3),thirdpart=translatedObj.slice(5e3);sendRequest(firstPart,projectId,part="first"),sendRequest(secondPart,projectId,part="second"),sendRequest(thirdpart,projectId,part="third")}else sendRequest(translatedObj,projectId,part="one")}function sendRequest(stringData,projectId,part){var data={action:"save_translations",data:JSON.stringify(stringData),part:part,"project-id":projectId};jQuery.post(ajaxUrl,data,(function(response){$("#loco-toolbar").find("button").each((function(i,el){var id;"auto"==el.getAttribute("data-loco")&&$(el).trigger("click")}))}))}window.onclick=function(event){event.target==gModal&&(gModal.style.display="none")},$("#atlt_strings_model").find(".close").on("click",(function(){$("#atlt_strings_model").fadeOut("slow")})),$("#atlt_yandex_transate_btn").on("click",(function(){var defaultcode=locale.lang?locale.lang:null,arr;switch(defaultcode){case"bel":defaultlang="be";break;case"he":defaultlang="iw";break;case"snd":defaultlang="sd";break;case"jv":defaultlang="jv";break;case"nb":case"nn":defaultlang="no";break;default:defaultlang=defaultcode}$(".save_it").prop("disabled",!0),$(".ytstats").css("display","none"),localStorage.setItem("lang",defaultlang),["af","jv","no","am","ar","az","ba","be","bg","bn","bs","ca","ceb","cs","cy","da","de","el","en","eo","es","et","eu","fa","fi","fr","ga","gd","gl","gu","he","hi","hr","ht","hu","hy","id","is","it","ja","jv","ka","kk","km","kn","ko","ky","la","lb","lo","lt","lv","mg","mhr","mi","mk","ml","mn","mr","mrj","ms","mt","my","ne","nl","no","pa","pap","pl","pt","ro","ru","si","sk","sl","sq","sr","su","sv","sw","ta","te","tg","th","tl","tr","tt","udm","uk","ur","uz","vi","xh","yi","zh"].includes(defaultlang)||($(".notice-container").addClass("notice inline notice-warning").html("Yandex Automatic Translator Does not support this language."),$(".string_container").hide(),$(".choose-lang").hide(),$(".save_it").hide(),$("#ytWidget").hide());var plainStrArr=filterRawObject(allStrings,"plain");plainStrArr.length>0?printStringsInPopup(plainStrArr,type="yandex"):($("#ytWidget").hide(),$(".notice-container").addClass("notice inline notice-warning").html("There is no plain string available for translations."),$(".string_container").hide(),$(".choose-lang").hide(),$(".save_it").hide()),$("#atlt-dialog").dialog("close"),$("#atlt_strings_model").addClass("yandex-translator").fadeIn("slow")}));var rpl={'"% s"':'"%s"','"% d"':'"%d"','"% S"':'"%s"','"% D"':'"%d"',"% s":" %s ","% S":" %s ","% d":" %d ","% D":" %d ","٪ s":" %s ","٪ S":" %s ","٪ d":" %d ","٪ D":" %d ","٪ س":" %s "};function filterRawObject(rawArray,filterType){return filterdArr=[],filterdArr=rawArray.filter((item,index)=>{if(""!==item.source&&void 0!==item.source&&(void 0===item.target||""==item.target))return!ValidURL(item.source)&&(!isHTML(item.source)&&(!!isPlacehodersChars(item.source)||!isSpecialChars(item.source)&&(!isEmoji(item.source)&&!item.source.includes("#"))))})}function ValidURL(str){var pattern;return!!/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(str)}function isHTML(str){var rgex;return void 0!==str&&/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i.test(str)}function isSpecialChars(str){var rgex;return void 0!==str&&/[@^{}|<>]/g.test(str)}function isEmoji(str){var ranges=["(?:[✀-➿]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[#-9]️?⃣|㊙|㊗|〽|〰|Ⓜ|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|🆎|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|🈚|🈯|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|‼|⁉|[▪-▫]|▶|◀|[◻-◾]|©|®|™|ℹ|🀄|[☀-⛿]|⬅|⬆|⬇|⬛|⬜|⭐|⭕|⌚|⌛|⌨|⏏|[⏩-⏳]|[⏸-⏺]|🃏|⤴|⤵|[←-⇿])"];return!!str.match(ranges.join("|"))}function isPlacehodersChars(str){var rgex;return void 0!==str&&/%s|%d/g.test(str)}function strtr(s,p,r){return!!s&&{2:function(){for(var i in p)s=strtr(s,i,p[i]);return s},3:function(){return s.replace(RegExp(p,"g"),r)},0:function(){}}[arguments.length]()}$(".save_it").on("click",(function(){var translatedObj=[];$("#stringTemplate tbody tr").each((function(index){var index=$(this).find("td.source").text(),target=$(this).find("td.target").text(),source=$(this).find("td.source").text(),improvedTarget=strtr(target,rpl),improvedSource=strtr(source,rpl);translatedObj.push({source:improvedSource,target:improvedTarget})}));var projectId=$(this).parents("#atlt_strings_model").find("#project_id").val();saveTranslatedStrings(translatedObj,projectId);var translatedObj=[];$(".atlt_custom_model").fadeOut("slow"),$("html").addClass("merge-translations");var checkModal=setInterval((function(){$(".loco-modal").length&&String($(".loco-modal").attr("style")).indexOf("block")>-1&&($("html").removeClass("merge-translations"),$("select#auto-api").hide(),$("#loco-auto a.icon-help").hide(),$("#loco-auto #loco-job-progress").hide(),$("select#auto-api option[value='loco_auto']").prop("selected","selected"),$("select#auto-api").val($("select#auto-api option[value='loco_auto']").val()),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Step 3 - Add Translations into Editor and Save"),$("#loco-auto button.button-primary span").html("Start Adding Process"),$("#loco-auto button.button-primary").on("click",(function(){$(this).find("span").html("Adding...")})),$(".loco-modal").addClass("addtranslations"),$(".noapiadded").remove(),$(".loco-modal #loco-auto form").show(),$(".loco-modal #loco-auto").removeClass("loco-alert"),clearInterval(checkModal))}),100)})),$("button.icon-robot[data-loco='auto']").on("click",(function(e){if(void 0!==e.originalEvent){$(".loco-modal").removeClass("addtranslations"),$("select#auto-api").show(),$("#loco-auto a.icon-help").show(),$("#loco-auto #loco-job-progress").show(),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("Auto-translate this file"),$("#loco-auto button.button-primary span").html("Translate");var opt=0;setTimeout((function(){$("select#auto-api option").each((function(){opt+=1})),1==opt&&($(".noapiadded").remove(),$(".loco-modal #loco-auto").removeClass("loco-alert"),$(".loco-modal #loco-auto form").hide(),$(".loco-modal #loco-auto").addClass("loco-alert"),$(".loco-modal .ui-dialog-titlebar .ui-dialog-title").html("No translation APIs configured"),$(".loco-modal #loco-auto").append("<div class='noapiadded'><p>Add automatic translation services in the plugin settings.<br>or<br>Use <strong>Auto Translate</strong> addon button.</p><nav><a href='http://locotranslate.local/wp-admin/admin.php?page=loco-config&amp;action=apis' class='has-icon icon-cog'>Settings</a><a href='https://localise.biz/wordpress/plugin/manual/providers?utm_medium=plugin&amp;utm_campaign=wp&amp;utm_source=admin&amp;utm_content=plugin-file-edit' class='has-icon icon-help' target='_blank'>Help</a></nav></div>"))}),400)}}))}(window,jQuery);
assets/js/loco-js-editor.js DELETED
@@ -1,1274 +0,0 @@
1
- /**
2
- * Script for PO file editor pages
3
- */
4
- !function( window, $ ){
5
-
6
- var loco = window.locoScope,
7
- conf = window.conf,
8
- fileRefs = loco.po.ref.init(loco,conf),
9
-
10
- syncParams = null,
11
- saveParams = null,
12
- ajaxUpload = conf.multipart,
13
-
14
- // UI translation
15
- translator = loco.l10n,
16
- sprintf = loco.string.sprintf,
17
-
18
- // PO file data
19
- locale = conf.locale,
20
- messages = loco.po.init( locale ).wrap( conf.powrap ),
21
- template = ! locale,
22
-
23
- // form containing action buttons
24
- elForm = document.getElementById('loco-actions'),
25
- filePath = conf.popath,
26
- syncPath = conf.potpath,
27
-
28
- // file system connect when file is locked
29
- elFilesys = document.getElementById('loco-fs'),
30
- fsConnect = elFilesys && loco.fs.init( elFilesys ),
31
-
32
- // prevent all write operations if readonly mode
33
- readonly = conf.readonly,
34
- editable = ! readonly,
35
-
36
- // Editor components
37
- editor,
38
- saveButton,
39
- innerDiv = document.getElementById('loco-editor-inner'),
40
-
41
- // validation and suggestions
42
- translationClients,
43
- translationApiKeys = conf.apis || [],
44
- suggestionCache = {},
45
-
46
- // modal windows
47
- $suggestModal,
48
- $translateModal;
49
-
50
- // warn if ajax uploads are enabled but not supported
51
- if( ajaxUpload && ! ( window.FormData && window.Blob ) ){
52
- ajaxUpload = false;
53
- loco.notices.warn("Your browser doesn't support Ajax file uploads. Falling back to standard postdata");
54
- }
55
-
56
-
57
- /**
58
- *
59
- */
60
- function doSyncAction( callback ){
61
- function onSuccess( result ){
62
- var info = [],
63
- doc = messages,
64
- exp = result.po,
65
- src = result.pot,
66
- pot = loco.po.init().load( exp ),
67
- done = doc.merge( pot ),
68
- nadd = done.add.length,
69
- ndel = done.del.length,
70
- t = translator;
71
- // reload even if unchanged, cos indexes could be off
72
- editor.load( doc );
73
- // Show summary
74
- if( nadd || ndel ){
75
- if( src ){
76
- // Translators: Where %s is the name of the POT template file. Message appears after sync
77
- info.push( sprintf( t._('Merged from %s'), src ) );
78
- }
79
- else {
80
- // Translators: Message appears after sync operation
81
- info.push( t._('Merged from source code') );
82
- }
83
- // Translators: Summary of new strings after running in-editor Sync
84
- nadd && info.push( sprintf( t._n('1 new string added','%s new strings added', nadd ), nadd ) );
85
- // Translators: Summary of existing strings that no longer exist after running in-editor Sync
86
- ndel && info.push( sprintf( t._n('1 obsolete string removed','%s obsolete strings removed', ndel ), ndel ) );
87
- // editor thinks it's saved, but we want the UI to appear otherwise
88
- $(innerDiv).trigger('poUnsaved',[]);
89
- updateStatus();
90
- // debug info in lieu of proper merge confirmation:
91
- window.console && debugMerge( console, done );
92
- }
93
- else if( src ){
94
- // Translators: Message appears after sync operation when nothing has changed. %s refers to a POT file.
95
- info.push( sprintf( t._('Already up to date with %s'), src ) );
96
- }
97
- else {
98
- // Translators: Message appears after sync operation when nothing has changed
99
- info.push( t._('Already up to date with source code') );
100
- }
101
- loco.notices.success( info.join('. ') );
102
- $(innerDiv).trigger('poMerge',[result]);
103
- // done sync
104
- callback && callback();
105
- }
106
- loco.ajax.post( 'sync', syncParams, onSuccess, callback );
107
- }
108
-
109
-
110
-
111
- function debugMerge( console, result ){
112
- var i = -1, t = result.add.length;
113
- while( ++i < t ){
114
- console.log(' + '+result.add[i].source() );
115
- }
116
- i = -1, t = result.del.length;
117
- while( ++i < t ){
118
- console.log(' - '+result.del[i].source() );
119
- }
120
- }
121
-
122
-
123
-
124
- // API client getters
125
- function createTranslationClients() {
126
- var i = -1, info, clients = [], keys = translationApiKeys, num = keys.length;
127
- while( ++i < num ){
128
- try {
129
- info = keys[i];
130
- clients.push( loco.apis.create(info) );
131
- }
132
- catch( Er ){
133
- loco.notices.error( String(Er) );
134
- }
135
- }
136
- return clients;
137
- }
138
-
139
- function getTranslationClients(){
140
- return translationClients || ( translationClients = createTranslationClients() );
141
- }
142
-
143
- function getTranslationClient(id){
144
- // not indexed as object, annoyingly.
145
- var client, clients = getTranslationClients(), num = clients.length, i = -1;
146
- while( ++i < num ){
147
- client = clients[i];
148
- if( client.getId() === id ){
149
- return client;
150
- }
151
- }
152
- loco.notices.error('No '+id+' client');
153
- }
154
-
155
-
156
- // Calling external translation providers
157
-
158
- function onHintEvent( /*event*/ ){
159
- translationApiKeys.length ? loadSuggestions() : loadUnconfiguredApis();
160
- }
161
-
162
-
163
- function getTranslationModal(){
164
- if( ! $translateModal ){
165
- $translateModal = $('#loco-auto');
166
- // http://api.jqueryui.com/dialog/
167
- $translateModal.dialog({
168
- dialogClass: 'loco-modal',
169
- appendTo: '#loco.wrap',
170
- title: $translateModal.attr('title'),
171
- modal: true,
172
- closeOnEscape: true,
173
- resizable: false,
174
- position: { my: "top", at: "top", of: '#loco-content' }
175
- } );
176
- }
177
- return $translateModal;
178
- }
179
-
180
-
181
-
182
- function loadUnconfiguredApis(){
183
- getTranslationModal().dialog('open');
184
- }
185
-
186
-
187
- function initAutoTranslate(){
188
- var job,
189
- credit,
190
- translated = 0,
191
- t = translator,
192
- flagFuzzy = false,
193
- $modal = getTranslationModal().dialog('open'),
194
- $form = $modal.find('form'),
195
- $butt = $form.find('button.button-primary'),
196
- $stat = $('#loco-job-progress')
197
- ;
198
- function enable(){
199
- $butt[0].disabled = false;
200
- }
201
- function disable(){
202
- $butt[0].disabled = true;
203
- }
204
- function think(){
205
- $butt.addClass('loco-loading');
206
- }
207
- function unthink(){
208
- $butt.removeClass('loco-loading');
209
- }
210
- function showStatus( message ){
211
- $stat.text(message);
212
- }
213
- // calculate job with current spec. not async. should be fast
214
- function refreshJob( elForm ){
215
- var apiId = $(elForm['api']).val(),
216
- client = getTranslationClient(apiId),
217
- overwrite = elForm['existing'].checked
218
- ;
219
- showStatus('Calculating....'); // <- won't render sync!
220
- job = client.createJob();
221
- job.init( messages, overwrite );
222
- credit = client.toString();
223
- showStatus(
224
- sprintf( t._('%s unique source strings.'), job.length.format(0) )+' '+
225
- // translators: characters meaning individual unicode characters of source text
226
- sprintf( t._('%s characters will be sent for translation.'), job.chars.format(0) )
227
- );
228
- // job ready for dispatch.
229
- job.length ? enable() : disable();
230
- }
231
- // refresh job if specification changes
232
- function onJobChange( event ){
233
- var elField = event.target, f = elField.name;
234
- if( 'api' === f || 'existing' === f ){
235
- refreshJob(elField.form);
236
- }
237
- return true;
238
- }
239
- // dispatch job if form submitted
240
- function onJobDispatch( event ){
241
- event.preventDefault();
242
- think();
243
- disable();
244
- onProgress(0);
245
- flagFuzzy = event.target['fuzzy'].checked;
246
- job.dispatch().done(onJobComplete).each(onEachTranslatedMessage).prog(onProgress);
247
- }
248
- function onEachTranslatedMessage(message){
249
- if( job ){
250
- flagFuzzy && message.fuzzy(0,true);
251
- editor.pasteMessage(message);
252
- if( message === editor.active ){
253
- editor.setStatus(message);
254
- }
255
- editor.unsave(message,0);
256
- translated++;
257
- }
258
- }
259
- // can't redraw translated count between messages, but can between batches!
260
- function onProgress(didBatches,numBatches){
261
- var percent = numBatches ? 100*didBatches/numBatches : 0;
262
- // translators: %s%% is a percentage, e.g. 50%
263
- showStatus( sprintf( t._('Translation progress %s%%'),percent.format(0)) );
264
- }
265
- function onJobComplete(){
266
- unthink();
267
- if( job ){
268
- var remaining = job.length - translated;
269
- if( remaining > 0 ) {
270
- translated && loco.notices.warn( sprintf( t._('Translation job aborted with %s strings remaining'),remaining.format(0) ) );
271
- }
272
- if( translated > 0 ){
273
- loco.notices.success( sprintf(t._('%s strings translated via '+credit), translated.format(0) ) ).stick();
274
- // update stats and reindex
275
- updateStatus();
276
- editor.rebuildSearch();
277
- }
278
- job = null;
279
- editor.fire('poAbort'); // <- hack allows re-enable of Auto buttons.
280
- }
281
- // close and destroy modal without recursion
282
- if( $modal ){
283
- $modal.off('dialogclose').dialog('close');
284
- $modal = null;
285
- }
286
- }
287
- // destructor
288
- function onCloseModal(){
289
- job.abort();
290
- $modal = null;
291
- onJobComplete();
292
- }
293
- // clean UI for new run
294
- unthink();
295
- disable();
296
- // initialize default job and listen for changes to spec
297
- $form.off('submit change')
298
- refreshJob( $form[0] );
299
- $form.on('change',onJobChange).on('submit',onJobDispatch);
300
- $modal.off('dialogclose').on('dialogclose',onCloseModal)
301
- }
302
-
303
-
304
-
305
- function loadSuggestions(){
306
- var t = translator,
307
- message = editor.current(),
308
- index = editor.getTargetOffset(),
309
- source = message && message.source(null,index),
310
- langAtts = 'lang="'+String(locale)+'" dir="'+(locale.isRTL()?'RTL':'LTR')+'"'
311
- ;
312
- if( source ){
313
- function createSuggestionClosure( source, target ){
314
- return function(event){
315
- event.preventDefault();
316
- event.stopPropagation();
317
- destroyScope();
318
-
319
- // use this translation.
320
- var message = editor.current(), index = editor.getTargetOffset();
321
- if( message && message.source(null,index) === source ){
322
- message.translate(target,index);
323
- editor.focus().reloadMessage(message)
324
- // editor.fuzzy(true,message,index); // TODO make optional
325
- }
326
- else {
327
- loco.notices.warn('Source changed since suggestion');
328
- }
329
- }
330
- }
331
- function completeSuggestion( source, target, locale, client ){
332
- var id = client.getId(), href = client.getUrl(), name = String(client), $div = placeholders && placeholders[id];
333
- $div && $div.replaceWith( $('<div class="loco-api loco-api-'+id+'"></div>')
334
- .append( $('<a class="loco-api-credit" target="_blank"></a>').attr('href',href).text(name) )
335
- .append( $('<blockquote '+langAtts+'></blockquote>').text(target||'[FAILED]') )
336
- .append( $('<button class="button button-primary"></button>').text(t._('Use this translation')).on('click',createSuggestionClosure(source,target)) )
337
- );
338
- // adjust position after each write
339
- $modal.dialog('option','position', { my: "center", at: "center", of: window });
340
- // are we done?
341
- if( ++loaded === length ){
342
- $modal && $modal.dialog('option','title', t._('Suggested translations')+' — '+locale.label );
343
- }
344
- }
345
- function initSuggestion( client ){
346
- var $div = $('<div class="loco-api loco-api-loading"></div>').text('Calling '+client+' ...');
347
- placeholders[ client.getId() ] = $div;
348
- return $div;
349
- }
350
- function destroyScope( closeEvent ){
351
- if( $modal && null == closeEvent ) {
352
- $modal.dialog('close');
353
- }
354
- $modal = null;
355
- placeholders = null;
356
- // TODO abort existing requests not yet returned
357
- }
358
- // closure ensures client that made call is available
359
- function createCallbackClosure( client ){
360
- return function( source, target, locale ){
361
- cached[ client.getId() ] = target;
362
- completeSuggestion(source, target, locale, client );
363
- }
364
- }
365
- // http://api.jqueryui.com/dialog/
366
- function getModal(){
367
- return $suggestModal || ( $suggestModal = $('<div id="loco-hint"></div>').dialog( {
368
- dialogClass : 'loco-modal',
369
- modal : true,
370
- autoOpen : false,
371
- closeOnEscape : true,
372
- resizable : false,
373
- minHeight : 400
374
- } ) );
375
- }
376
- // open modal for loading suggestions, starting with source
377
- var $modal = getModal().html('').append( $('<div class="loco-api"><p>Source text:</p></div>').append( $('<blockquote lang="en"></blockquote>').text(source) ) )
378
- .dialog('option','title', t._('Loading suggestions')+'...' )
379
- .off('dialogclose').on('dialogclose',destroyScope)
380
- .dialog('open')
381
- ;
382
- // show existing translation if there is one
383
- var target = message.translation(index);
384
- if( target ){
385
- $('<div class="loco-api"><p>Current translation:</p></div>')
386
- .append( $('<blockquote '+langAtts+'></blockquote>').text(target) )
387
- .append( $('<button class="button"></button>').text(t._('Keep this translation')).on('click',function(event){
388
- event.preventDefault();
389
- destroyScope();
390
- }) )
391
- .appendTo($modal)
392
- ;
393
- }
394
- // request translation from each api in *parallel* browser should handle queueing if required
395
- var client, clientId, clients = getTranslationClients(), length = clients.length, i = -1,
396
- cached = suggestionCache[source] || ( suggestionCache[source] = {} ),
397
- placeholders = {},
398
- loaded = 0
399
- ;
400
- while( ++i < length ){
401
- client = clients[i];
402
- $modal.append( initSuggestion(client) );
403
- // setTimeout( completeSuggestion, fakeDelay*(i+1), source,source,locale,client);
404
- clientId = client.getId();
405
- if( cached[clientId] ){
406
- completeSuggestion(source,cached[clientId],locale,client);
407
- }
408
- else {
409
- client.translate( source, locale, createCallbackClosure(client) );
410
- }
411
- }
412
- }
413
- }
414
-
415
-
416
- /**
417
- * Capture clicks on file references
418
- */
419
- function onMetaClick( event, target ){
420
- function tryTag( node, name ){
421
- if( node.tagName === name ){
422
- return node;
423
- }
424
- return node.getElementsByTagName(name)[0];
425
- }
426
- var codeEl = tryTag(target,'CODE');
427
- if( codeEl ){
428
- fileRefs.load( codeEl.textContent );
429
- }
430
- }
431
-
432
-
433
- /**
434
- * @param params {Object}
435
- * @return FormData
436
- */
437
- function initMultiPart( params ){
438
- var p, data = new FormData;
439
- for( p in params ){
440
- if( params.hasOwnProperty(p) ) {
441
- data.append(p, params[p]);
442
- }
443
- }
444
- return data;
445
- }
446
-
447
-
448
- /**
449
- * Post full editor contents to "posave" endpoint
450
- */
451
- function doSaveAction( callback ){
452
-
453
- function onSuccess( result ){
454
- callback && callback();
455
- editor.save( true );
456
- // Update saved time update
457
- $('#loco-po-modified').text( result.datetime||'[datetime error]' );
458
- }
459
- var postData = $.extend( {locale:String(messages.locale()||'')}, saveParams||{} );
460
- if( fsConnect ){
461
- fsConnect.applyCreds(postData);
462
- }
463
- // submit PO as concrete file if configured
464
- if( ajaxUpload ){
465
- postData = initMultiPart(postData);
466
- postData.append('po', new Blob([String(messages)],{type:'application/x-gettext'}), String(postData.path).split('/').pop()||'untitled.po' );
467
- }
468
- else {
469
- postData.data = String(messages);
470
- }
471
- loco.ajax.post( 'save', postData, onSuccess, callback );
472
- }
473
-
474
-
475
- function saveIfDirty(){
476
- editor.dirty && doSaveAction();
477
- }
478
-
479
-
480
-
481
- function onUnloadWarning(){
482
- // Translators: Warning appears when user tries to refresh or navigate away when editor work is unsaved
483
- return translator._("Your changes will be lost if you continue without saving");
484
- }
485
-
486
-
487
-
488
- function registerSaveButton( button ){
489
- saveButton = button;
490
- // enables and disable according to save/unsave events
491
- editor
492
- .on('poUnsaved', function(){
493
- enable();
494
- $(button).addClass( 'button-primary loco-flagged' );
495
- } )
496
- .on('poSave', function(){
497
- disable();
498
- $(button).removeClass( 'button-primary loco-flagged' );
499
- } )
500
- ;
501
- function disable(){
502
- button.disabled = true;
503
- }
504
- function enable(){
505
- button.disabled = false;
506
- }
507
- function think(){
508
- disable();
509
- $(button).addClass('loco-loading');
510
- }
511
- function unthink(){
512
- enable();
513
- $(button).removeClass('loco-loading');
514
- }
515
- saveParams = $.extend( { path: filePath }, conf.project||{} );
516
-
517
- $(button).click( function(event){
518
- event.preventDefault();
519
- think();
520
- doSaveAction( unthink );
521
- return false;
522
- } );
523
- return true;
524
- };
525
-
526
-
527
-
528
- function registerSyncButton( button ){
529
- var project = conf.project;
530
- if( project ){
531
- function disable(){
532
- button.disabled = true;
533
- }
534
- function enable(){
535
- button.disabled = false;
536
- }
537
- function think(){
538
- disable();
539
- $(button).addClass('loco-loading');
540
- }
541
- function unthink(){
542
- enable();
543
- $(button).removeClass('loco-loading');
544
- }
545
- // Only permit sync when document is saved
546
- editor
547
- .on('poUnsaved', function(){
548
- disable();
549
- } )
550
- .on('poSave', function(){
551
- enable();
552
- } )
553
- ;
554
- // params for sync end point
555
- syncParams = {
556
- bundle: project.bundle,
557
- domain: project.domain,
558
- type: template ? 'pot' : 'po',
559
- sync: syncPath||''
560
- };
561
- // enable syncing on button click
562
- $(button)
563
- .click( function(event){
564
- event.preventDefault();
565
- think();
566
- doSyncAction( unthink );
567
- return false;
568
- } )
569
- //.attr('title', syncPath ? sprintf( translator._('Update from %s'), syncPath ) : translator._('Update from source code') )
570
- ;
571
- enable();
572
- }
573
- return true;
574
- }
575
-
576
-
577
- function registerAutoTranslateButton( button ){
578
- function disable(){
579
- button.disabled = true;
580
- }
581
- function enable(){
582
- button.disabled = false;
583
- }
584
- // like Sync, only allow processing when file is saved
585
- editor
586
- .on('poUnsaved', function(){
587
- disable();
588
- } )
589
- .on('poSave poAbort', function(){
590
- enable();
591
- } )
592
- ;
593
- // click opens modal unless open already
594
- $(button).click( function( event ){
595
- event.preventDefault();
596
- initAutoTranslate();
597
- return false;
598
- } );
599
- enable();
600
- return true;
601
- }
602
-
603
-
604
-
605
- /*function registerFuzzyButton( button ){
606
- var toggled = false,
607
- enabled = false
608
- ;
609
- function redraw( message, state ){
610
- // fuzziness only makes sense when top-level string is translated
611
- var allowed = message && message.translated(0) || false;
612
- if( enabled !== allowed ){
613
- button.disabled = ! allowed;
614
- enabled = allowed;
615
- }
616
- // toggle on/off according to new fuzziness
617
- if( state !== toggled ){
618
- $(button)[ state ? 'addClass' : 'removeClass' ]('inverted');
619
- toggled = state;
620
- }
621
- }
622
- // state changes depending on whether an asset is selected and is fuzzy
623
- editor
624
- .on('poSelected', function( event, message ){
625
- redraw( message, message && message.fuzzy() || false );
626
- } )
627
- .on( 'poEmpty', function( event, blank, message, pluralIndex ){
628
- if( 0 === pluralIndex && blank === enabled ){
629
- redraw( message, toggled );
630
- }
631
- } )
632
- .on( 'poFuzzy', function( event, message, newState ){
633
- redraw( message, newState );
634
- } )
635
- ;
636
- // click toggles current state
637
- $(button).click( function( event ){
638
- event.preventDefault();
639
- editor.fuzzy( ! editor.fuzzy() );
640
- return false;
641
- } );
642
- return true;
643
- };*/
644
-
645
-
646
-
647
- function registerRevertButton( button ){
648
- // No need for revert when document is saved
649
- editor
650
- .on('poUnsaved', function(){
651
- button.disabled = false;
652
- } )
653
- .on('poSave', function(){
654
- button.disabled = true;
655
- } )
656
- ;
657
- // handling unsaved state prompt with onbeforeunload, see below
658
- $(button).click( function( event ){
659
- event.preventDefault();
660
- location.reload();
661
- return false;
662
- } );
663
- return true;
664
- };
665
-
666
-
667
-
668
- function registerInvisiblesButton( button ){
669
- var $button = $(button);
670
- button.disabled = false;
671
- editor.on('poInvs', function( event, state ){
672
- $button[ state ? 'addClass' : 'removeClass' ]('inverted');
673
- });
674
- $button.click( function( event ){
675
- event.preventDefault();
676
- editor.setInvs( ! editor.getInvs() );
677
- return false;
678
- } );
679
- locoScope.tooltip.init($button);
680
- return true;
681
- }
682
-
683
-
684
-
685
- function registerCodeviewButton( button ){
686
- var $button = $(button);
687
- button.disabled = false;
688
- $button.click( function(event){
689
- event.preventDefault();
690
- var state = ! editor.getMono();
691
- $button[ state ? 'addClass' : 'removeClass' ]('inverted');
692
- editor.setMono(state);
693
- return false;
694
- } );
695
- locoScope.tooltip.init($button);
696
- return true;
697
- };
698
-
699
-
700
-
701
- function registerAddButton( button ){
702
- button.disabled = false;
703
- $(button).click( function( event ){
704
- event.preventDefault();
705
- // Need a placeholder guaranteed to be unique for new items
706
- var i = 1, baseid, msgid, regex = /(\d+)$/;
707
- msgid = baseid = 'New message';
708
- while( messages.get( msgid ) ){
709
- i = regex.exec(msgid) ? Math.max(i,RegExp.$1) : i;
710
- msgid = baseid+' '+( ++i );
711
- }
712
- editor.add( msgid );
713
- return false;
714
- } );
715
- return true;
716
- };
717
-
718
-
719
-
720
- function registerDelButton( button ){
721
- button.disabled = false;
722
- $(button).click( function(event){
723
- event.preventDefault();
724
- editor.del();
725
- return false;
726
- } );
727
- return true;
728
- };
729
-
730
-
731
-
732
- function registerDownloadButton( button, id ){
733
- button.disabled = false;
734
- $(button).click( function( event ){
735
- var form = button.form,
736
- path = filePath;
737
- // swap out path
738
- if( 'binary' === id ){
739
- path = path.replace(/\.po$/,'.mo');
740
- }
741
- form.path.value = path;
742
- form.source.value = messages.toString();
743
- // allow form to submit
744
- return true;
745
- } );
746
- return true;
747
- }
748
-
749
-
750
- // event handler that stops dead
751
- function noop( event ){
752
- event.preventDefault();
753
- return false;
754
- }
755
-
756
-
757
- /*/ dummy function for enabling buttons that do nothing (or do something inherently)
758
- function registerNoopButton( button ){
759
- return true;
760
- }*/
761
-
762
-
763
-
764
- /**
765
- * Update status message above editor.
766
- * This is dynamic version of PHP Loco_gettext_Metadata::getProgressSummary
767
- * TODO implement progress bar, not just text.
768
- */
769
- function updateStatus(){
770
- var t = translator,
771
- stats = editor.stats(),
772
- total = stats.t,
773
- fuzzy = stats.f,
774
- empty = stats.u,
775
- // Translators: Shows total string count at top of editor
776
- stext = sprintf( t._n('1 string','%s strings',total ), total.format(0) ),
777
- extra = [];
778
- if( locale ){
779
- // Translators: Shows percentage translated at top of editor
780
- stext = sprintf( t._('%s%% translated'), stats.p.replace('%','') ) +', '+ stext;
781
- // Translators: Shows number of fuzzy strings at top of editor
782
- fuzzy && extra.push( sprintf( t._('%s fuzzy'), fuzzy.format(0) ) );
783
- // Translators: Shows number of untranslated strings at top of editor
784
- empty && extra.push( sprintf( t._('%s untranslated'), empty.format(0) ) );
785
- if( extra.length ){
786
- stext += ' ('+extra.join(', ')+')';
787
- }
788
- }
789
- $('#loco-po-status').text( stext );
790
- }
791
-
792
-
793
-
794
- /**
795
- * Enable text filtering
796
- */
797
- function initSearchFilter( elSearch ){
798
- editor.searchable( loco.fulltext.init() );
799
- // prep search text field
800
- elSearch.disabled = false;
801
- elSearch.value = '';
802
- function showValidFilter( numFound ){
803
- $(elSearch.parentNode)[ numFound || null == numFound ? 'removeClass' : 'addClass' ]('invalid');
804
- }
805
- var listener = loco.watchtext( elSearch, function( value ){
806
- var numFound = editor.filter( value, true );
807
- showValidFilter( numFound );
808
- } );
809
- editor
810
- .on( 'poFilter', function( event, value, numFound ){
811
- listener.val( value||'' );
812
- showValidFilter( numFound );
813
- } )
814
- .on( 'poMerge', function( event, result ){
815
- var value = listener.val();
816
- value && editor.filter( value );
817
- } )
818
- ;
819
- }
820
-
821
-
822
-
823
- // resize function fits editor to screen, accounting for headroom and touching bottom of screen.
824
- var resize = function(){
825
- function top( el, ancestor ){
826
- var y = el.offsetTop||0;
827
- while( ( el = el.offsetParent ) && el !== ancestor ){
828
- y += el.offsetTop||0;
829
- }
830
- return y;
831
- }
832
- var fixHeight,
833
- minHeight = parseInt($(innerDiv).css('min-height')||0)
834
- ;
835
- return function(){
836
- var padBottom = 20,
837
- topBanner = top( innerDiv, document.body ),
838
- winHeight = window.innerHeight,
839
- setHeight = Math.max( minHeight, winHeight - topBanner - padBottom )
840
- ;
841
- if( fixHeight !== setHeight ){
842
- innerDiv.style.height = String(setHeight)+'px';
843
- fixHeight = setHeight;
844
- }
845
- };
846
- }();
847
-
848
- // ensure outer resize is handled before editor's internal resize
849
- resize();
850
- $(window).resize( resize );
851
-
852
- // initialize editor
853
- innerDiv.innerHTML = '';
854
- editor = loco.po.ed
855
- .init( innerDiv )
856
- .localise( translator )
857
- ;
858
-
859
- loco.po.kbd
860
- .init( editor )
861
- .add('save', saveIfDirty )
862
- .add('hint', locale && editable && onHintEvent || noop )
863
- .enable('copy','clear','enter','next','prev','fuzzy','save','invis','hint')
864
- ;
865
-
866
- // initialize toolbar button actions
867
- var buttons = {
868
- // help: registerNoopButton,
869
- save: editable && registerSaveButton,
870
- sync: editable && registerSyncButton,
871
- revert: registerRevertButton,
872
- // editor mode togglers
873
- invs: registerInvisiblesButton,
874
- code: registerCodeviewButton,
875
- // download buttons
876
- source: registerDownloadButton,
877
- binary: template ? null : registerDownloadButton
878
- };
879
- // POT only
880
- if( template ){
881
- buttons.add = editable && registerAddButton;
882
- buttons.del = editable && registerDelButton;
883
- }
884
- // PO only
885
- else {
886
- buttons.auto = registerAutoTranslateButton;
887
- }
888
- $('#loco-toolbar').find('button').each( function(i,el){
889
- var id = el.getAttribute('data-loco'), register = buttons[id];
890
- register && register(el,id) || $(el).hide();
891
- } );
892
-
893
- // disable submit on dummy form
894
- $(elForm).submit( noop );
895
-
896
- // enable text filtering
897
- initSearchFilter( document.getElementById('loco-search') );
898
-
899
- // editor event behaviours
900
- editor
901
- .on('poUnsaved', function(){
902
- window.onbeforeunload = onUnloadWarning;
903
- } )
904
- .on('poSave', function(){
905
- updateStatus();
906
- window.onbeforeunload = null;
907
- } )
908
- .on('poHint', onHintEvent )
909
- .on('poUpdate', updateStatus )
910
- .on('poMeta', onMetaClick )
911
- ;
912
-
913
- // load raw message data
914
- messages.load( conf.podata );
915
-
916
- // ready to render editor
917
- editor.load( messages );
918
-
919
- // locale should be cast to full object once set in editor
920
- locale = editor.targetLocale;
921
- if( locale ){
922
- locale.isRTL() && $(innerDiv).addClass('trg-rtl');
923
- }
924
- // enable template mode when no target locale
925
- else {
926
- editor.unlock();
927
- }
928
-
929
- // ok, editor ready
930
- updateStatus();
931
-
932
- /*---------------------custom Code---------------*/
933
-
934
- /*
935
- since version 1.1
936
- Google Translate Popup handlers
937
- */
938
-
939
- newaddAutoTranslationBtn();
940
-
941
-
942
- // integrates auto traslator button in editor
943
- function newaddAutoTranslationBtn(){
944
- if($("#loco-toolbar").find("#cool-auto-translate-btn").length>0){
945
- $("#loco-toolbar").find("#cool-auto-translate-btn").remove();
946
- }
947
- const locoActions= $("#loco-toolbar").find("#loco-actions");
948
- const otherBtn='<button class="button has-icon icon-warn" id="atlt_reset_all">Reset Translations</button></fieldset>';
949
- const allTranslated='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate" disabled>Translated</button></fieldset>';
950
- const proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';
951
- locoActions.append(proActiveBtn);
952
- }
953
-
954
- // open popup on autotranslate button click
955
- $("#cool-auto-translate-btn").on("click",function(){
956
- createPopup();
957
- });
958
- // create auto translate popup
959
- function createPopup(){
960
- $( "#atlt-dialog" ).dialog({
961
- resizable: false,
962
- height: "auto",
963
- width: 400,
964
- modal: true,
965
- buttons: {
966
- Cancel: function() {
967
- $( this ).dialog( "close" );
968
- }
969
- }
970
- });
971
- }
972
-
973
- // Get the button that opens the modal
974
- // var gTranslateBtn = document.getElementById("atlt_gtranslate_btn");
975
-
976
- // When the user clicks the button, open the modal
977
- $("#atlt_yandex_transate_btn").on("click",function() {
978
- var defaultcode = window.conf.locale.lang?window.conf.locale.lang:null;
979
- switch(defaultcode){
980
- case 'bel':
981
- defaultlang='be';
982
- break;
983
- case 'he':
984
- defaultlang='iw';
985
- break;
986
- case'snd':
987
- defaultlang='sd';
988
- break;
989
- case 'jv':
990
- defaultlang='jw';
991
- break;
992
- default:
993
- defaultlang=defaultcode;
994
- break;
995
- }
996
- $(".save_it").prop("disabled",true);
997
- $(".ytstats").hide();
998
- localStorage.setItem("lang",defaultlang);
999
- var arr = ['af','am', 'ar','az','ba','be','bg','bn', 'bs','ca','ceb','cs','cy','da','de','el','en','eo','es','et','eu', 'fa', 'fi','fr','ga','gd','gl','gu', 'he','hi','hr','ht','hu','hy','id','is','it','ja','jv','ka','kk','km','kn','ko','ky','la','lb','lo','lt','lv','mg','mhr','mi','mk', 'ml','mn', 'mr','mrj','ms','mt','my','ne','nl','no','pa','pap','pl','pt','ro','ru','si','sk','sl','sq', 'sr', 'su', 'sv','sw','ta','te','tg','th','tl','tr','tt','udm','uk','ur','uz','vi','xh','yi', 'zhCN'];
1000
- if(arr.includes(defaultlang)){
1001
- // googleTranslateElementInit();
1002
- }
1003
- else{
1004
- $(".string_container").after("<strong>Yandex Automatic Translator Does not support this language.</strong>");
1005
- $(".string_container").hide();
1006
- $(".save_it").hide();
1007
- $("#ytWidget").hide();
1008
- }
1009
- // get only plain strings
1010
- var plainStrArr= filterRawObject(conf.podata,"plain");
1011
- if (plainStrArr.length>0) {
1012
- printStringsInPopup(plainStrArr, type="yandex");
1013
- }else{
1014
- $("#ytWidget").hide();
1015
- $(".string_container").after("<strong>There is no plain string available for translations.</strong>");
1016
- $(".string_container").hide();
1017
- $(".save_it").hide();
1018
- }
1019
- $("#atlt-dialog").dialog("close");
1020
- $("#atlt_strings_model").addClass("yandex-translator").fadeIn("slow");
1021
-
1022
- });
1023
-
1024
- /*
1025
- load strings in popup table
1026
- */
1027
- function printStringsInPopup(jsonObj,type){
1028
- var replaceit={};
1029
- var html='';
1030
- var totalTChars=0;
1031
- var index=1;
1032
- if(jsonObj){
1033
- for (const key in jsonObj) {
1034
- if (jsonObj.hasOwnProperty(key)) {
1035
- const element = jsonObj[key];
1036
- if(element.source!=''){
1037
- if(type=="yandex"){
1038
- html +='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+'</td>';
1039
- }
1040
- else{
1041
- if(key>2500){
1042
- break;
1043
- }
1044
- html +='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+'</td>';
1045
- }
1046
- if(type=="yandex"){
1047
- html +='<td translate="yes" class="target translate">'+element.source+'</td></tr>';
1048
- }else{
1049
- html +='<td class="target translate"></td></tr>';
1050
- }
1051
- index++;
1052
- totalTChars +=element.source.length;
1053
- }
1054
- }
1055
- }
1056
- $(".ytstats").each(function(){
1057
- $(this).find(".totalChars").html(totalTChars);
1058
- });
1059
- }
1060
- if(type=="yandex"){
1061
- $("#yandex_string_tbl").append(html);
1062
- }
1063
- }
1064
-
1065
- /*
1066
- Save Translated Strings
1067
- */
1068
- var rpl = {
1069
- '"% s"': '"%s"',
1070
- '"% d"': '"%d"',
1071
- '"% S"': '"%s"',
1072
- '"% D"': '"%d"',
1073
- '% s': ' %s ',
1074
- '% S': ' %s ',
1075
- '% d': ' %d ',
1076
- '% D': ' %d ',
1077
- '٪ s': ' %s ',
1078
- '٪ S': ' %s ',
1079
- '٪ d': ' %d ',
1080
- '٪ D': ' %d ',
1081
- '٪ س': ' %s '
1082
- };
1083
- var translatedObj=[];
1084
- $(".save_it").on("click",function(){
1085
- $("#stringTemplate tbody tr").each(function(index){
1086
- var string=$(this).find("td.target").text();
1087
- translatedObj.push(string);
1088
- });
1089
- saveTranslatedStrings(translatedObj);
1090
- $(".atlt_custom_model").fadeOut("slow");
1091
- });
1092
-
1093
-
1094
- // mark unsaved after ajax translation process
1095
- function markUnsavedString(){
1096
- const unSavedString = JSON.parse(localStorage.getItem('unSavedString'));
1097
-
1098
- for(var x=0;x<=unSavedString.length;x++){
1099
- var source = unSavedString[x];
1100
- jQuery("#po-list-tbody div[for='po-list-col-source'] div").filter(function(index){
1101
- return jQuery(this).text() == source
1102
- }).addClass('po-unsaved');
1103
- }
1104
- }
1105
-
1106
- // save translated string in popup
1107
- function saveTranslatedStrings(translatedObj){
1108
- var plainStrArr= filterRawObject(conf.podata,"plain");
1109
- const saveBtn=$('[data-loco="save"]');
1110
- if(translatedObj!==undefined && translatedObj.length){
1111
- for(i=0;i< translatedObj.length;i++){
1112
- var text = translatedObj[i];
1113
- if( plainStrArr[i] === undefined ){
1114
- break;
1115
- }
1116
- plainStrArr[i].target = strtr(text,rpl) ;
1117
- }
1118
- }
1119
-
1120
- messages = loco.po.init( locale ).wrap( conf.powrap );
1121
- // ready to render editor
1122
- messages.load(conf.podata);
1123
-
1124
- markUnsaved(plainStrArr);
1125
- // editor event behaviours
1126
- editor
1127
- .on('poUnsaved', function(){
1128
- window.onbeforeunload = onUnloadWarning;
1129
- } )
1130
- .on('poSave', function(){
1131
- updateStatus();
1132
- window.onbeforeunload = null;
1133
- } )
1134
- .on( 'poUpdate', updateStatus );
1135
-
1136
- // ready to render editor
1137
- editor.load(messages);
1138
- saveBtn.addClass( 'button-primary loco-flagged' ).removeAttr("disabled");
1139
- updateStatus();
1140
- }
1141
-
1142
- // replace placeholders in strings
1143
- function strtr(s, p, r) {
1144
- return !!s && {
1145
- 2: function () {
1146
- for (var i in p) {
1147
- s = strtr(s, i, p[i]);
1148
- }
1149
- return s;
1150
- },
1151
- 3: function () {
1152
- return s.replace(RegExp(p, 'g'), r);
1153
- },
1154
- 0: function () {
1155
- return;
1156
- }
1157
- }[arguments.length]();
1158
- }
1159
-
1160
- // filter string based upon type
1161
- function filterRawObject(rawArray,filterType){
1162
- filterdArr=[];
1163
- return filterdArr=rawArray.filter((item,index)=>{
1164
- if((item.source!=="" && item.source!==undefined) && (item.target===undefined || item.target=="")){
1165
- if( ValidURL(item.source)){
1166
- return false;
1167
- }
1168
- if(isHTML(item.source)){
1169
- return false;
1170
- }
1171
- else if(isPlacehodersChars(item.source)){
1172
- return true;
1173
- }
1174
- else if(isSpecialChars(item.source)){
1175
- return false;
1176
- }else if( item.source.includes('#') ) {
1177
- return false;
1178
- }else{
1179
- return true;
1180
- }
1181
- }
1182
- });
1183
- }
1184
-
1185
-
1186
- // detect String contain URL
1187
- function ValidURL(str) {
1188
- var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
1189
- if(!pattern.test(str)) {
1190
- return false;
1191
- } else {
1192
- return true;
1193
- }
1194
- }
1195
- // detect Valid HTML in string
1196
- function isHTML(str){
1197
- var rgex=/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i;
1198
- if(str!==undefined){
1199
- return rgex.test(str);
1200
- }else {
1201
- return false;
1202
- }
1203
- }
1204
- // check special chars in string
1205
- function isSpecialChars(str){
1206
- var rgex=/[@#^$%&*{}|<>]/g;
1207
- if(str!==undefined){
1208
- return rgex.test(str);
1209
- }else {
1210
- return false;
1211
- }
1212
- }
1213
- // allowed special chars in HTML string
1214
- function isAllowedChars(str){
1215
- var rgex=/[!@#$%^&*(),?":|<>]/g;
1216
- if(str!==undefined){
1217
- return rgex.test(str);
1218
- }else {
1219
- return false;
1220
- }
1221
- }
1222
-
1223
- // allowed special chars in plain text
1224
- function isPlacehodersChars(str){
1225
- var rgex=/%s|%d/g;
1226
- if(str!==undefined){
1227
- return rgex.test(str);
1228
- }else {
1229
- return false;
1230
- }
1231
- }
1232
- // check string contain curly brackets
1233
- function isContainChars(str){
1234
- var rgex=/[{}[]/g;
1235
- if(str!==undefined){
1236
- return rgex.test(str);
1237
- }else {
1238
- return false;
1239
- }
1240
- }
1241
-
1242
- // mark unsaved strings
1243
- function markUnsaved(data){
1244
-
1245
- for (const key in data) {
1246
-
1247
- if (data.hasOwnProperty(key)) {
1248
- let element = data[key]['message'];
1249
- if(data[key]['source']==""){
1250
- continue;
1251
- }
1252
- // flagFuzzy && message.fuzzy(0,true);
1253
- editor.pasteMessage(element);
1254
- if( element === editor.active ){
1255
- editor.setStatus(element);
1256
- }
1257
- editor.unsave(element,0);
1258
-
1259
- }
1260
- }
1261
-
1262
- }
1263
-
1264
- // format numbers
1265
- function atltFormatNumber(num) {
1266
- return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
1267
- }
1268
-
1269
- /*---------------------end------------------*/
1270
- // clean up
1271
- // delete window.locoConf;
1272
- //conf = buttons = null;
1273
-
1274
- }( window, jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/loco-js-editor.min.js DELETED
@@ -1 +0,0 @@
1
- !function(window,$){var loco=window.locoScope,conf=window.conf,fileRefs=loco.po.ref.init(loco,conf),syncParams=null,saveParams=null,ajaxUpload=conf.multipart,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"),translationClients,translationApiKeys=conf.apis||[],suggestionCache={},$suggestModal,$translateModal;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 createTranslationClients(){for(var i=-1,info,clients=[],keys=translationApiKeys,num=keys.length;++i<num;)try{info=keys[i],clients.push(loco.apis.create(info))}catch(Er){loco.notices.error(String(Er))}return clients}function getTranslationClients(){return translationClients||(translationClients=createTranslationClients())}function getTranslationClient(id){for(var client,clients=getTranslationClients(),num=clients.length,i=-1;++i<num;)if((client=clients[i]).getId()===id)return client;loco.notices.error("No "+id+" client")}function onHintEvent(){translationApiKeys.length?loadSuggestions():loadUnconfiguredApis()}function getTranslationModal(){return $translateModal||($translateModal=$("#loco-auto")).dialog({dialogClass:"loco-modal",appendTo:"#loco.wrap",title:$translateModal.attr("title"),modal:!0,closeOnEscape:!0,resizable:!1,position:{my:"top",at:"top",of:"#loco-content"}}),$translateModal}function loadUnconfiguredApis(){getTranslationModal().dialog("open")}function initAutoTranslate(){var job,credit,translated=0,t=translator,flagFuzzy=!1,$modal=getTranslationModal().dialog("open"),$form=$modal.find("form"),$butt=$form.find("button.button-primary"),$stat=$("#loco-job-progress");function enable(){$butt[0].disabled=!1}function disable(){$butt[0].disabled=!0}function think(){$butt.addClass("loco-loading")}function unthink(){$butt.removeClass("loco-loading")}function showStatus(message){$stat.text(message)}function refreshJob(elForm){var apiId,client=getTranslationClient($(elForm.api).val()),overwrite=elForm.existing.checked;showStatus("Calculating...."),(job=client.createJob()).init(messages,overwrite),credit=client.toString(),showStatus(sprintf(t._("%s unique source strings."),job.length.format(0))+" "+sprintf(t._("%s characters will be sent for translation."),job.chars.format(0))),job.length?enable():disable()}function onJobChange(event){var elField=event.target,f=elField.name;return"api"!==f&&"existing"!==f||refreshJob(elField.form),!0}function onJobDispatch(event){event.preventDefault(),think(),disable(),onProgress(0),flagFuzzy=event.target.fuzzy.checked,job.dispatch().done(onJobComplete).each(onEachTranslatedMessage).prog(onProgress)}function onEachTranslatedMessage(message){job&&(flagFuzzy&&message.fuzzy(0,!0),editor.pasteMessage(message),message===editor.active&&editor.setStatus(message),editor.unsave(message,0),translated++)}function onProgress(didBatches,numBatches){var percent=numBatches?100*didBatches/numBatches:0;showStatus(sprintf(t._("Translation progress %s%%"),percent.format(0)))}function onJobComplete(){if(unthink(),job){var remaining=job.length-translated;remaining>0&&translated&&loco.notices.warn(sprintf(t._("Translation job aborted with %s strings remaining"),remaining.format(0))),translated>0&&(loco.notices.success(sprintf(t._("%s strings translated via "+credit),translated.format(0))).stick(),updateStatus(),editor.rebuildSearch()),job=null,editor.fire("poAbort")}$modal&&($modal.off("dialogclose").dialog("close"),$modal=null)}function onCloseModal(){job.abort(),$modal=null,onJobComplete()}unthink(),disable(),$form.off("submit change"),refreshJob($form[0]),$form.on("change",onJobChange).on("submit",onJobDispatch),$modal.off("dialogclose").on("dialogclose",onCloseModal)}function loadSuggestions(){var t=translator,message=editor.current(),index=editor.getTargetOffset(),source=message&&message.source(null,index),langAtts='lang="'+String(locale)+'" dir="'+(locale.isRTL()?"RTL":"LTR")+'"';if(source){function createSuggestionClosure(source,target){return function(event){event.preventDefault(),event.stopPropagation(),destroyScope();var message=editor.current(),index=editor.getTargetOffset();message&&message.source(null,index)===source?(message.translate(target,index),editor.focus().reloadMessage(message)):loco.notices.warn("Source changed since suggestion")}}function completeSuggestion(source,target,locale,client){var id=client.getId(),href=client.getUrl(),name=String(client),$div=placeholders&&placeholders[id];$div&&$div.replaceWith($('<div class="loco-api loco-api-'+id+'"></div>').append($('<a class="loco-api-credit" target="_blank"></a>').attr("href",href).text(name)).append($("<blockquote "+langAtts+"></blockquote>").text(target||"[FAILED]")).append($('<button class="button button-primary"></button>').text(t._("Use this translation")).on("click",createSuggestionClosure(source,target)))),$modal.dialog("option","position",{my:"center",at:"center",of:window}),++loaded===length&&$modal&&$modal.dialog("option","title",t._("Suggested translations")+" — "+locale.label)}function initSuggestion(client){var $div=$('<div class="loco-api loco-api-loading"></div>').text("Calling "+client+" ...");return placeholders[client.getId()]=$div,$div}function destroyScope(closeEvent){$modal&&null==closeEvent&&$modal.dialog("close"),$modal=null,placeholders=null}function createCallbackClosure(client){return function(source,target,locale){cached[client.getId()]=target,completeSuggestion(source,target,locale,client)}}function getModal(){return $suggestModal||($suggestModal=$('<div id="loco-hint"></div>').dialog({dialogClass:"loco-modal",modal:!0,autoOpen:!1,closeOnEscape:!0,resizable:!1,minHeight:400}))}var $modal=getModal().html("").append($('<div class="loco-api"><p>Source text:</p></div>').append($('<blockquote lang="en"></blockquote>').text(source))).dialog("option","title",t._("Loading suggestions")+"...").off("dialogclose").on("dialogclose",destroyScope).dialog("open"),target=message.translation(index);target&&$('<div class="loco-api"><p>Current translation:</p></div>').append($("<blockquote "+langAtts+"></blockquote>").text(target)).append($('<button class="button"></button>').text(t._("Keep this translation")).on("click",(function(event){event.preventDefault(),destroyScope()}))).appendTo($modal);for(var client,clientId,clients=getTranslationClients(),length=clients.length,i=-1,cached=suggestionCache[source]||(suggestionCache[source]={}),placeholders={},loaded=0;++i<length;)client=clients[i],$modal.append(initSuggestion(client)),clientId=client.getId(),cached[clientId]?completeSuggestion(source,cached[clientId],locale,client):client.translate(source,locale,createCallbackClosure(client))}}function onMetaClick(event,target){function tryTag(node,name){return node.tagName===name?node:node.getElementsByTagName(name)[0]}var codeEl=tryTag(target,"CODE");codeEl&&fileRefs.load(codeEl.textContent)}function initMultiPart(params){var p,data=new FormData;for(p in params)params.hasOwnProperty(p)&&data.append(p,params[p]);return data}function doSaveAction(callback){function onSuccess(result){callback&&callback(),editor.save(!0),$("#loco-po-modified").text(result.datetime||"[datetime error]")}var postData=$.extend({locale:String(messages.locale()||"")},saveParams||{});fsConnect&&fsConnect.applyCreds(postData),ajaxUpload?(postData=initMultiPart(postData)).append("po",new Blob([String(messages)],{type:"application/x-gettext"}),String(postData.path).split("/").pop()||"untitled.po"):postData.data=String(messages),loco.ajax.post("save",postData,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),!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 registerAutoTranslateButton(button){function disable(){button.disabled=!0}function enable(){button.disabled=!1}return editor.on("poUnsaved",(function(){disable()})).on("poSave poAbort",(function(){enable()})),$(button).click((function(event){return event.preventDefault(),initAutoTranslate(),!1})),enable(),!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 $button[state?"addClass":"removeClass"]("inverted"),editor.setMono(state),!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)}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)}))}!ajaxUpload||window.FormData&&window.Blob||(ajaxUpload=!1,loco.notices.warn("Your browser doesn't support Ajax file uploads. Falling back to standard postdata"));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).add("hint",locale&&editable&&onHintEvent||noop).enable("copy","clear","enter","next","prev","fuzzy","save","invis","hint");var buttons={save:editable&&registerSaveButton,sync:editable&&registerSyncButton,revert:registerRevertButton,invs:registerInvisiblesButton,code:registerCodeviewButton,source:registerDownloadButton,binary:template?null:registerDownloadButton};function newaddAutoTranslationBtn(){$("#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>',proActiveBtn='<fieldset><button id="cool-auto-translate-btn" class="button has-icon icon-translate">Auto Translate</button></fieldset>';locoActions.append(proActiveBtn)}function createPopup(){$("#atlt-dialog").dialog({resizable:!1,height:"auto",width:400,modal:!0,buttons:{Cancel:function(){$(this).dialog("close")}}})}function printStringsInPopup(jsonObj,type){var html="",totalTChars=0,index=1;if(jsonObj){for(const key in jsonObj)if(jsonObj.hasOwnProperty(key)){const element=jsonObj[key];if(""!=element.source){if("yandex"==type)html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+"</td>";else{if(key>2500)break;html+='<tr id="'+key+'" ><td>'+index+'</td><td class="notranslate source">'+element.source+"</td>"}html+="yandex"==type?'<td translate="yes" class="target translate">'+element.source+"</td></tr>":'<td class="target translate"></td></tr>',index++,totalTChars+=element.source.length}}$(".ytstats").each((function(){$(this).find(".totalChars").html(totalTChars)}))}"yandex"==type&&$("#yandex_string_tbl").append(html)}template?(buttons.add=editable&&registerAddButton,buttons.del=editable&&registerDelButton):buttons.auto=registerAutoTranslateButton,$("#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("poHint",onHintEvent).on("poUpdate",updateStatus).on("poMeta",onMetaClick),messages.load(conf.podata),editor.load(messages),(locale=editor.targetLocale)?locale.isRTL()&&$(innerDiv).addClass("trg-rtl"):editor.unlock(),updateStatus(),newaddAutoTranslationBtn(),$("#cool-auto-translate-btn").on("click",(function(){createPopup()})),$("#atlt_yandex_transate_btn").on("click",(function(){var defaultcode=window.conf.locale.lang?window.conf.locale.lang:null,arr;switch(defaultcode){case"bel":defaultlang="be";break;case"he":defaultlang="iw";break;case"snd":defaultlang="sd";break;case"jv":defaultlang="jw";break;default:defaultlang=defaultcode}$(".save_it").prop("disabled",!0),$(".ytstats").hide(),localStorage.setItem("lang",defaultlang),["af","am","ar","az","ba","be","bg","bn","bs","ca","ceb","cs","cy","da","de","el","en","eo","es","et","eu","fa","fi","fr","ga","gd","gl","gu","he","hi","hr","ht","hu","hy","id","is","it","ja","jv","ka","kk","km","kn","ko","ky","la","lb","lo","lt","lv","mg","mhr","mi","mk","ml","mn","mr","mrj","ms","mt","my","ne","nl","no","pa","pap","pl","pt","ro","ru","si","sk","sl","sq","sr","su","sv","sw","ta","te","tg","th","tl","tr","tt","udm","uk","ur","uz","vi","xh","yi","zhCN"].includes(defaultlang)||($(".string_container").after("<strong>Yandex Automatic Translator Does not support this language.</strong>"),$(".string_container").hide(),$(".save_it").hide(),$("#ytWidget").hide());var plainStrArr=filterRawObject(conf.podata,"plain");plainStrArr.length>0?printStringsInPopup(plainStrArr,type="yandex"):($("#ytWidget").hide(),$(".string_container").after("<strong>There is no plain string available for translations.</strong>"),$(".string_container").hide(),$(".save_it").hide()),$("#atlt-dialog").dialog("close"),$("#atlt_strings_model").addClass("yandex-translator").fadeIn("slow")}));var rpl={'"% s"':'"%s"','"% d"':'"%d"','"% S"':'"%s"','"% D"':'"%d"',"% s":" %s ","% S":" %s ","% d":" %d ","% D":" %d ","٪ s":" %s ","٪ S":" %s ","٪ d":" %d ","٪ D":" %d ","٪ س":" %s "},translatedObj=[];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 saveTranslatedStrings(translatedObj){var plainStrArr=filterRawObject(conf.podata,"plain");const saveBtn=$('[data-loco="save"]');if(void 0!==translatedObj&&translatedObj.length)for(i=0;i<translatedObj.length;i++){var text=translatedObj[i];if(void 0===plainStrArr[i])break;plainStrArr[i].target=strtr(text,rpl)}(messages=loco.po.init(locale).wrap(conf.powrap)).load(conf.podata),markUnsaved(plainStrArr),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()}function strtr(s,p,r){return!!s&&{2:function(){for(var i in p)s=strtr(s,i,p[i]);return s},3:function(){return s.replace(RegExp(p,"g"),r)},0:function(){}}[arguments.length]()}function filterRawObject(rawArray,filterType){return filterdArr=[],filterdArr=rawArray.filter((item,index)=>{if(""!==item.source&&void 0!==item.source&&(void 0===item.target||""==item.target))return!ValidURL(item.source)&&(!isHTML(item.source)&&(!!isPlacehodersChars(item.source)||!isSpecialChars(item.source)&&!item.source.includes("#")))})}function ValidURL(str){var pattern;return!!/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/.test(str)}function isHTML(str){var rgex;return void 0!==str&&/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i.test(str)}function isSpecialChars(str){var rgex;return void 0!==str&&/[@#^$%&*{}|<>]/g.test(str)}function 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 markUnsaved(data){for(const key in data)if(data.hasOwnProperty(key)){let element=data[key].message;if(""==data[key].source)continue;editor.pasteMessage(element),element===editor.active&&editor.setStatus(element),editor.unsave(element,0)}}function atltFormatNumber(num){return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")}$(".save_it").on("click",(function(){$("#stringTemplate tbody tr").each((function(index){var string=$(this).find("td.target").text();translatedObj.push(string)})),saveTranslatedStrings(translatedObj),$(".atlt_custom_model").fadeOut("slow")}))}(window,jQuery);
 
assets/js/widget.js CHANGED
@@ -110,6 +110,7 @@
110
  }, false);
111
 
112
  form.addEventListener('change', function (event) {
 
113
  var target = event.target;
114
  if (target.checked) {
115
  self.onChange(target.value);
@@ -202,10 +203,11 @@
202
  };
203
 
204
  select.onChange = function (lang) {
 
205
  storage.setValue('lang', lang);
206
  rightButton.setText(lang);
207
  self.setState('invalid', lang === pageLang);
208
- updatePopupSettings();
209
  };
210
 
211
  select.onHiddenChange = function (hidden) {
@@ -258,11 +260,13 @@
258
  break;
259
  }
260
  });
 
 
261
  function updatePopupSettings(){
262
  var container=$("#atlt_strings_model");
263
  container.find(".string_container").scrollTop(0);
264
  var scrollHeight= container.find('.string_container').get(0).scrollHeight;
265
- var scrollSpeed=1000;
266
  if(scrollHeight > scrollSpeed){
267
  scrollSpeed = scrollHeight;
268
  }
@@ -299,8 +303,8 @@
299
  }
300
  else{
301
  setTimeout(() => {
302
- container.find(".save_it").prop("disabled",false);
303
- container.find(".ytstats").fadeIn("slow");
304
  }, 2000);
305
  }
306
  }
@@ -327,8 +331,22 @@
327
  select.setHidden(true);
328
  };
329
  // defaultLang = storage.getValue('lang') || userLang;
330
- var defaultcode = window.conf.locale.lang?window.conf.locale.lang:null;
331
- defaultLang = defaultcode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  if (defaultLang) {
333
  select.setValue(defaultLang);
334
  active = storage.getValue('active');
110
  }, false);
111
 
112
  form.addEventListener('change', function (event) {
113
+ alert("form change state");
114
  var target = event.target;
115
  if (target.checked) {
116
  self.onChange(target.value);
203
  };
204
 
205
  select.onChange = function (lang) {
206
+
207
  storage.setValue('lang', lang);
208
  rightButton.setText(lang);
209
  self.setState('invalid', lang === pageLang);
210
+ // updatePopupSettings();
211
  };
212
 
213
  select.onHiddenChange = function (hidden) {
260
  break;
261
  }
262
  });
263
+
264
+ // custom code
265
  function updatePopupSettings(){
266
  var container=$("#atlt_strings_model");
267
  container.find(".string_container").scrollTop(0);
268
  var scrollHeight= container.find('.string_container').get(0).scrollHeight;
269
+ var scrollSpeed=800;
270
  if(scrollHeight > scrollSpeed){
271
  scrollSpeed = scrollHeight;
272
  }
303
  }
304
  else{
305
  setTimeout(() => {
306
+ // container.find(".save_it").prop("disabled",false);
307
+ // container.find(".ytstats").fadeIn("slow");
308
  }, 2000);
309
  }
310
  }
331
  select.setHidden(true);
332
  };
333
  // defaultLang = storage.getValue('lang') || userLang;
334
+ if(window.locoConf.conf!=undefined){
335
+ var defaultcode = window.locoConf.conf.locale.lang?window.locoConf.conf.locale.lang:null;
336
+ }
337
+ switch(defaultcode){
338
+ case 'nb':
339
+ defaultLang='no';
340
+ break;
341
+
342
+ case 'nn':
343
+ defaultLang='no';
344
+ break;
345
+ default:
346
+ defaultLang= defaultcode;
347
+ break;
348
+ }
349
+ // defaultLang = defaultcode;
350
  if (defaultLang) {
351
  select.setValue(defaultLang);
352
  active = storage.getValue('active');
automatic-translator-addon-for-loco-translate.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
  Description:Auto language translator add-on for Loco Translate official plugin version 2.4.0 to translate plugins and themes translation files into any language via fully automatic machine translations via Yandex Translate Widget.
5
- Version:2.0.1
6
  License:GPL2
7
  Text Domain:loco-translate-addon
8
  Domain Path:languages
@@ -14,7 +14,7 @@ use LocoAutoTranslateAddon\Helpers\Helpers;
14
  use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
15
  /**
16
  * @package Loco Automatic Translate Addon
17
- * @version 2.0.1
18
  */
19
  if (!defined('ABSPATH')) {
20
  die('WordPress Environment Not Found!');
@@ -23,7 +23,7 @@ if (!defined('ABSPATH')) {
23
  define('ATLT_FILE', __FILE__);
24
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
25
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
26
- define('ATLT_VERSION', '2.0.1');
27
 
28
  class LocoAutoTranslate
29
  {
@@ -32,13 +32,12 @@ class LocoAutoTranslate
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
  add_action('admin_notices', array($this,'atlt_plugins_compatibility_check') );
37
  // Only loged in user can perform this AJAX 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'));
41
- add_action( 'admin_enqueue_scripts', array( $this,'atlt_enqueue_scripts') );
42
  add_action('init',array($this,'checkStatus'));
43
  add_action('init',array($this,'updateSettings'));
44
  //add notice to use latest loco translate addon
@@ -54,27 +53,29 @@ class LocoAutoTranslate
54
  {
55
  add_action('admin_footer', array($this,'load_ytranslate_scripts'),100);
56
  }
57
-
58
- /* since version 2.0 */
59
- add_filter('script_loader_tag',array($this,'custom_remove_scripts'), 11, 2);
 
 
 
60
  }
61
  }
62
- /* Remove loco translate editor js file
63
- since version 2.0
64
- Created By:-Jyoti
65
- */
66
- function custom_remove_scripts($link, $handle) {
67
- if( !file_exists( WP_PLUGIN_DIR . '/loco-translate/loco.php' ) ){
68
- return $link;
69
- }
70
- $urls = array(
71
- plugins_url().'/loco-translate/pub/js/min/editor.js?ver=2.4.0'
72
- );
73
- foreach ($urls as $url) {
74
- if (strstr($link, $url)) {$link = '';}
75
- }
76
- return $link;
77
- }
78
  /*
79
  |----------------------------------------------------------------------
80
  | Yandex Translate Widget Integartions
@@ -226,7 +227,7 @@ class LocoAutoTranslate
226
  $title = "Loco Translate";
227
  $plugin_info = get_plugin_data(__FILE__, true, true);
228
  echo '<div class="error"><p>' .
229
- 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>',
230
  'loco-translate-addon'),
231
  $plugin_info['Name'], esc_url($url),
232
  esc_attr($title), esc_attr($title)) . '.</p></div>';
@@ -240,72 +241,58 @@ class LocoAutoTranslate
240
  | Enqueue required JS file
241
  |------------------------------------------------------------------------
242
  */
243
- function atlt_enqueue_scripts(){
244
 
245
  // load assets only on editor page
246
- if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
247
- {
248
- wp_deregister_script('loco-js-editor');
249
- // copy object
250
- wp_add_inline_script( 'loco-translate-js-admin', 'var loco = window.locoScope;
251
- var target={};
252
- var returnedTarget = Object.assign(target, window.locoConf);
253
- window.conf=returnedTarget;' );
254
- }
255
-
256
-
257
- // load yandex widget
258
- wp_register_script( 'atlt-yandex-widget', ATLT_URL.'assets/js/widget.js?widgetId=ytWidget&pageLang=en&widgetTheme=light&autoMode=false',array('jquery'),ATLT_VERSION, true);
 
 
 
259
 
260
- if(Helpers::userType()=="free"){
261
- // register styles
262
- wp_register_style('loco-addon-custom-css', ATLT_URL.'assets/css/custom.min.css',null,
263
- ATLT_VERSION,'all');
264
- // wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_VERSION, true);
265
- wp_register_script( 'loco-addon-custom', ATLT_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_VERSION, true);
266
- wp_register_script( 'custom-loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_VERSION, true);
267
  }else{
268
- // if PRO version is installed then load assets
269
- if(Helpers::proInstalled() && version_compare(ATLT_PRO_VERSION,'1.1', '>=')){
270
- $key=Helpers::getLicenseKey();
271
- if(Helpers::validKey( $key)){
272
- wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.min.css',null,
273
- ATLT_VERSION,'all');
274
- wp_register_script( 'loco-addon-custom', ATLT_PRO_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_PRO_VERSION, true);
275
- wp_register_script( 'custom-loco-js-editor', ATLT_PRO_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_PRO_VERSION, true);
276
- wp_register_script( 'sweet-alert', ATLT_PRO_URL.'assets/sweetalert/sweetalert.min.js', array('jquery'),ATLT_PRO_VERSION, true);
277
- }
278
- }else{
279
- wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.min.css',null,
280
  ATLT_VERSION,'all');
281
- // wp_register_script( 'loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.js', array('loco-js-min-admin'),ATLT_VERSION, true);
282
- wp_register_script( 'loco-addon-custom', ATLT_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_VERSION, true);
283
- wp_register_script( 'custom-loco-js-editor', ATLT_URL.'assets/js/loco-js-editor.min.js', array('loco-translate-js-editor'),ATLT_VERSION, true);
284
  }
285
- }
286
-
287
- // load assets only on editor page
288
- if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
289
- {
290
- // load common assets
291
- wp_enqueue_script('loco-addon-custom');
292
- wp_enqueue_script('custom-loco-js-editor');
293
- wp_enqueue_script('atlt-yandex-widget');
294
- wp_enqueue_style('loco-addon-custom-css');
295
 
296
- if(Helpers::userType()=="pro"){
297
- wp_enqueue_script('sweet-alert');
298
- }
299
-
300
- $extraData['preloader_path']=ATLT_URL.'/assets/images/preloader.gif';
301
- $extraData['gt_preview']=ATLT_URL.'/assets/images/powered-by-google.png';
302
- $extraData['dpl_preview']=ATLT_URL.'/assets/images/powered-by-deepl.png';
303
- $extraData['yt_preview']=ATLT_URL.'/assets/images/powered-by-yandex.png';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
305
- wp_localize_script('loco-addon-custom', 'extradata', $extraData);
306
-
307
- }
308
- }
309
 
310
  /**
311
  * Show Admin notice to users for Rollback if compatibility issue is raised by other plugin.
@@ -317,7 +304,7 @@ function atlt_plugins_compatibility_check(){
317
  $loco = get_plugin_data( WP_PLUGIN_DIR . '/loco-translate/loco.php',false);
318
  $pages = array('loco-plugin');
319
 
320
- if( isset( $_GET['atlt_rollback'] ) && $_GET['atlt_rollback'] == true && version_compare($loco['Version'] ,'2.4.0','>' )){
321
 
322
  $_POST['key'] = (isset( $_GET['hash'] ) && !empty( $_GET['hash'] ) ) ? $_GET['hash'] : null;
323
  // forbid direct access.
@@ -325,21 +312,30 @@ function atlt_plugins_compatibility_check(){
325
  echo sprintf(__('<div class="error" style="padding:5px;margin-top:50px;">Nonce verification failed! Click to <a href="'. admin_url('admin.php?page='.$_GET['page']) . '">refresh</a> this page.</div>','loco-translate-addon'));
326
  die();
327
  }
328
-
 
 
 
 
 
 
329
  require_once ATLT_PATH . 'includes/Helpers/Atlt_downloader.php';
330
  $request = new Atlt_downloader();
331
- echo $request->rollback( $url = 'https://downloads.wordpress.org/plugin/loco-translate.2.4.0.zip');
332
 
333
  echo sprintf(__('<br/><br/><a href="'. admin_url('admin.php?page='.$_GET['page']) . '">%s</a>','loco-translate-addon' ),'Refresh this page' );
334
  die();
335
 
336
- }else if( (isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'file-edit' ) && version_compare($loco['Version'] ,'2.4.0','>' ) ){
337
 
338
  $plugin_name = $atlt['Name'];
339
  // create nonce
340
  $hash = wp_create_nonce('atlt_nounce_rollback_loco');
 
341
  echo '<div class="notice notice-error" style="margin-top:50px;">' .
342
- sprintf(__('<p style="font-size:16px;"><strong>Notice: %s</strong> is currently compatible with Loco Translate official plugin version <strong>2.4.0</strong>. If you want to use this addon features then you can <a class="button button-primary" href="?page='.$_GET['page'].'&atlt_rollback=true&hash='.$hash.'" action="atlt_rollback" id="atlt_rollback240">Roll Back</a> Loco Translate official plugin to version 2.4.0 or you can just uninstall this addon to use Loco Translate latest version without this addon.<br/><br/><i>*We are working on an update to make <strong>Automatic Translate Addon For Loco Translate</strong> compatible with all future updates of Loco Translate official plugin and it will available soon.</i></p></div>',
 
 
343
  'loco-translate-addon') ,
344
  $plugin_name ) ;
345
 
@@ -347,6 +343,25 @@ function atlt_plugins_compatibility_check(){
347
 
348
  }
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  /*
351
  |------------------------------------------------------
352
  | Plugin activation
2
  /*
3
  Plugin Name:Automatic Translate Addon For Loco Translate
4
  Description:Auto language translator add-on for Loco Translate official plugin version 2.4.0 to translate plugins and themes translation files into any language via fully automatic machine translations via Yandex Translate Widget.
5
+ Version:2.1
6
  License:GPL2
7
  Text Domain:loco-translate-addon
8
  Domain Path:languages
14
  use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
15
  /**
16
  * @package Loco Automatic Translate Addon
17
+ * @version 2.1
18
  */
19
  if (!defined('ABSPATH')) {
20
  die('WordPress Environment Not Found!');
23
  define('ATLT_FILE', __FILE__);
24
  define('ATLT_URL', plugin_dir_url(ATLT_FILE));
25
  define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
26
+ define('ATLT_VERSION', '2.1');
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
  add_action('admin_notices', array($this,'atlt_plugins_compatibility_check') );
36
  // Only loged in user can perform this AJAX request
37
  add_action('plugins_loaded', array($this, 'atlt_check_required_loco_plugin'));
38
  /*** Template Setting Page Link inside Plugins List */
39
  add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this,'atlt_settings_page_link'));
40
+ add_action( 'admin_enqueue_scripts', array( $this,'atlt_enqueue_scripts') );
41
  add_action('init',array($this,'checkStatus'));
42
  add_action('init',array($this,'updateSettings'));
43
  //add notice to use latest loco translate addon
53
  {
54
  add_action('admin_footer', array($this,'load_ytranslate_scripts'),100);
55
  }
56
+
57
+ /* since version 2.1 */
58
+ add_filter('loco_api_providers',array($this,'register_loco_auto_translate_api'),10,1);
59
+ add_action('loco_api_ajax',array($this,'loco_auto_translate_ajax_init'),0,0);
60
+ add_action( 'wp_ajax_save_translations',array($this, 'save_all_translations') );
61
+
62
  }
63
  }
64
+
65
+ // since version 2.1
66
+ function loco_auto_translate_ajax_init(){
67
+ require __DIR__.'/includes/translator.php';
68
+ }
69
+ function register_loco_auto_translate_api( array $apis ){
70
+ $apis[] = array (
71
+ 'id' => 'loco_auto',
72
+ 'key' => '122343',
73
+ 'url' => '234324',
74
+ 'name' => 'Automatic Translate Addon',
75
+ );
76
+ return $apis;
77
+ }
78
+
 
79
  /*
80
  |----------------------------------------------------------------------
81
  | Yandex Translate Widget Integartions
227
  $title = "Loco Translate";
228
  $plugin_info = get_plugin_data(__FILE__, true, true);
229
  echo '<div class="error"><p>' .
230
+ 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>',
231
  'loco-translate-addon'),
232
  $plugin_info['Name'], esc_url($url),
233
  esc_attr($title), esc_attr($title)) . '.</p></div>';
241
  | Enqueue required JS file
242
  |------------------------------------------------------------------------
243
  */
244
+ function atlt_enqueue_scripts(){
245
 
246
  // load assets only on editor page
247
+ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'file-edit')
248
+ {
249
+
250
+ if(Helpers::userType()=="pro"){
251
+ // if PRO version is installed then load assets
252
+ if(Helpers::proInstalled())
253
+ {
254
+ $key=Helpers::getLicenseKey();
255
+ if(Helpers::validKey( $key)){
256
+ wp_register_script( 'loco-addon-custom', ATLT_PRO_URL.'assets/js/custom.min.js',
257
+ array('loco-translate-js-admin'),ATLT_PRO_VERSION, true);
258
+ wp_enqueue_script('loco-addon-custom');
259
+ wp_register_style('loco-addon-custom-css', ATLT_PRO_URL.'assets/css/custom.min.css',null,
260
+ ATLT_PRO_VERSION,'all');
261
+ }
262
+ }
263
 
 
 
 
 
 
 
 
264
  }else{
265
+ wp_register_script( 'loco-addon-custom', ATLT_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_VERSION, true);
266
+ wp_enqueue_script('loco-addon-custom');
267
+ wp_register_style('loco-addon-custom-css', ATLT_URL.'assets/css/custom.min.css',null,
 
 
 
 
 
 
 
 
 
268
  ATLT_VERSION,'all');
 
 
 
269
  }
270
+
 
 
 
 
 
 
 
 
 
271
 
272
+ wp_register_script( 'loco-addon-custom', ATLT_URL.'assets/js/custom.min.js', array('loco-translate-js-admin'),ATLT_VERSION, true);
273
+ wp_enqueue_script('loco-addon-custom');
274
+ wp_register_style('loco-addon-custom-css', ATLT_URL.'assets/css/custom.min.css',null,
275
+ ATLT_VERSION,'all');
276
+ // load yandex widget
277
+ wp_register_script( 'atlt-yandex-widget', ATLT_URL.'assets/js/widget.js?widgetId=ytWidget&pageLang=en&widgetTheme=light&autoMode=false',array('loco-translate-js-admin'),ATLT_VERSION, true);
278
+ wp_enqueue_script('atlt-yandex-widget');
279
+ wp_enqueue_style('loco-addon-custom-css');
280
+
281
+ $extraData['preloader_path']=ATLT_URL.'/assets/images/preloader.gif';
282
+ $extraData['gt_preview']=ATLT_URL.'/assets/images/powered-by-google.png';
283
+ $extraData['dpl_preview']=ATLT_URL.'/assets/images/powered-by-deepl.png';
284
+ $extraData['yt_preview']=ATLT_URL.'/assets/images/powered-by-yandex.png';
285
+ $extraData['ajax_url']=admin_url( 'admin-ajax.php' );
286
+ $extraData['nonce']=wp_create_nonce('loco-addon-nonces');
287
+
288
+ wp_localize_script('loco-addon-custom', 'extradata', $extraData);
289
+ // copy object
290
+ wp_add_inline_script( 'loco-translate-js-admin', '
291
+ var returnedTarget = JSON.parse(JSON.stringify(window.loco));
292
+ window.locoConf=returnedTarget;' );
293
+ }
294
+ }
295
 
 
 
 
 
296
 
297
  /**
298
  * Show Admin notice to users for Rollback if compatibility issue is raised by other plugin.
304
  $loco = get_plugin_data( WP_PLUGIN_DIR . '/loco-translate/loco.php',false);
305
  $pages = array('loco-plugin');
306
 
307
+ if( isset( $_GET['atlt_update'] ) && $_GET['atlt_update'] == true && version_compare($loco['Version'] ,'2.4.3','<' )){
308
 
309
  $_POST['key'] = (isset( $_GET['hash'] ) && !empty( $_GET['hash'] ) ) ? $_GET['hash'] : null;
310
  // forbid direct access.
312
  echo sprintf(__('<div class="error" style="padding:5px;margin-top:50px;">Nonce verification failed! Click to <a href="'. admin_url('admin.php?page='.$_GET['page']) . '">refresh</a> this page.</div>','loco-translate-addon'));
313
  die();
314
  }
315
+ $response = wp_remote_get("https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=loco-translate", array('timeout'=>300) );
316
+ if( is_wp_error($response)){
317
+ return;
318
+ }
319
+ $plugin_info = json_decode( $response['body'] );
320
+ $upgrade_link = $plugin_info->download_link;
321
+
322
  require_once ATLT_PATH . 'includes/Helpers/Atlt_downloader.php';
323
  $request = new Atlt_downloader();
324
+ echo $request->rollback( $upgrade_link, "Loco Translate updated successful!" );
325
 
326
  echo sprintf(__('<br/><br/><a href="'. admin_url('admin.php?page='.$_GET['page']) . '">%s</a>','loco-translate-addon' ),'Refresh this page' );
327
  die();
328
 
329
+ }else if( (isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'file-edit' ) && version_compare($loco['Version'] ,'2.4.3','<' ) ){
330
 
331
  $plugin_name = $atlt['Name'];
332
  // create nonce
333
  $hash = wp_create_nonce('atlt_nounce_rollback_loco');
334
+ $url = admin_url( "admin.php?page=".$_GET['page']."&atlt_update=true&hash=" . $hash );
335
  echo '<div class="notice notice-error" style="margin-top:50px;">' .
336
+ sprintf(__('<p style="font-size:16px;">
337
+ <strong>Notice: %s</strong> is only compatible with Loco Translate latest version 2.4.3 or higher.
338
+ </br><a class="button button-primary" href="'.$url.'" action="atlt_update" id="atlt_update">Update</a> Loco Translate official plugin to latest version to use this addon.</p></div>',
339
  'loco-translate-addon') ,
340
  $plugin_name ) ;
341
 
343
 
344
  }
345
 
346
+ function save_all_translations (){
347
+ if(isset($_POST['data']) && !empty($_POST['data'])){
348
+ $allStrings=json_decode(stripslashes($_POST['data']),true);
349
+ if($_POST['part']=="first"){
350
+ $projectId=$_POST['project-id'].'-first';
351
+ }else if($_POST['part']=="second"){
352
+ $projectId=$_POST['project-id'].'-second';
353
+ }
354
+ else if($_POST['part']=="third"){
355
+ $projectId=$_POST['project-id'].'-third';
356
+ }else{
357
+ $projectId=$_POST['project-id'];
358
+ }
359
+ $rs=set_transient($projectId,$allStrings,5* MINUTE_IN_SECONDS);
360
+ echo json_encode(array("Saved"=>"yes","res"=>$rs));
361
+ }
362
+ exit();
363
+ }
364
+
365
  /*
366
  |------------------------------------------------------
367
  | Plugin activation
includes/Helpers/Atlt_downloader.php CHANGED
@@ -16,7 +16,7 @@ namespace LocoAutoTranslateAddon\Helpers;
16
 
17
  class Atlt_downloader extends \Plugin_Upgrader{
18
 
19
- public function rollback($url = null){
20
 
21
  $key = ( isset( $_POST['key'] ) && !empty( $_POST['key'] ) ) ? $_POST['key'] : null;
22
 
@@ -48,6 +48,6 @@ namespace LocoAutoTranslateAddon\Helpers;
48
  if ( ! $this->result || is_wp_error( $this->result ) ) {
49
  return $this->result;
50
  }
51
- return 'Loco Translate rollback successful!';
52
  }
53
  }
16
 
17
  class Atlt_downloader extends \Plugin_Upgrader{
18
 
19
+ public function rollback($url = null, $response = 'Plugin updated successful!'){
20
 
21
  $key = ( isset( $_POST['key'] ) && !empty( $_POST['key'] ) ) ? $_POST['key'] : null;
22
 
48
  if ( ! $this->result || is_wp_error( $this->result ) ) {
49
  return $this->result;
50
  }
51
+ return $response;
52
  }
53
  }
includes/Register/LocoAutomaticTranslateAddonPro.php CHANGED
@@ -136,51 +136,68 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
136
  <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
137
  <input type="hidden" name="action" value="LocoAutomaticTranslateAddonPro_el_deactivate_license"/>
138
  <div class="el-license-container">
139
- <h3 class="el-license-title"><i class="dashicons-before dashicons-star-filled"></i> <?php _e("Automatic Translate Addon For Loco Translate - Premium License Status",$this->slug);?> </h3>
140
- <hr>
141
- <ul class="el-license-info">
142
- <li>
143
- <div>
144
- <span class="el-license-info-title"><?php _e("License Status",$this->slug);?></span>
 
 
145
 
146
- <?php if ( $this->responseObj->is_valid ) : ?>
147
- <span class="el-license-valid"><?php _e("Valid",$this->slug);?></span>
148
- <?php else : ?>
149
- <span class="el-license-valid"><?php _e("Invalid",$this->slug);?></span>
150
- <?php endif; ?>
151
- </div>
152
- </li>
153
 
154
- <li>
155
- <div>
156
- <span class="el-license-info-title"><?php _e("License Type",$this->slug);?></span>
157
- <?php echo $this->responseObj->license_title; ?>
158
- </div>
159
- </li>
160
 
161
- <li>
162
- <div>
163
- <span class="el-license-info-title"><?php _e("License Expiry Date",$this->slug);?></span>
164
- <?php echo $this->responseObj->expire_date; ?>
165
- </div>
166
- </li>
167
 
168
- <li>
169
- <div>
170
- <span class="el-license-info-title"><?php _e("Support Expiry Date",$this->slug);?></span>
171
- <?php echo $this->responseObj->support_end; ?>
172
- </div>
173
- </li>
174
- <li>
175
- <div>
176
- <span class="el-license-info-title"><?php _e("Your License Key",$this->slug);?></span>
177
- <span class="el-license-key"><?php echo esc_attr( substr($this->responseObj->license_key,0,9)."XXXXXXXX-XXXXXXXX".substr($this->responseObj->license_key,-9) ); ?></span>
 
 
 
 
 
 
178
  </div>
179
- </li>
180
- </ul>
181
- <div class="el-license-active-btn">
182
- <?php wp_nonce_field( 'el-license' ); ?>
183
- <?php submit_button('Deactivate License'); ?>
 
 
 
 
 
 
 
 
 
184
  </div>
185
  </div>
186
  </form>
@@ -192,110 +209,103 @@ require_once "LocoAutomaticTranslateAddonProBase.php";
192
  <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
193
  <input type="hidden" name="action" value="LocoAutomaticTranslateAddonPro_el_activate_license"/>
194
  <div class="el-license-container">
195
- <h3 class="el-license-title"><i class="dashicons-before dashicons-star-filled"></i> <?php _e("Automatic Translate Addon For Loco Translate - Premium License",$this->slug);?></h3>
196
- <hr>
197
- <?php
198
- if(!empty($this->showMessage) && !empty($this->licenseMessage)){
199
- ?>
200
- <div class="notice notice-error is-dismissible">
201
- <p><?php echo _e($this->licenseMessage,$this->slug); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  </div>
203
- <?php
204
- }
205
- ?>
206
- <style>
207
- table.loco-addon-license tr th, table.loco-addon-license tr td {
208
- border: 1px solid #bbb;
209
- padding: 12px;
210
- text-align: center;
211
- }
212
- table.loco-addon-license tr td strong img {
213
- height: 28px;
214
- width: auto;
215
- vertical-align: middle;
216
- }
217
- </style>
218
- <!--Enter License Key Here START-->
219
- <div class="el-license-field">
220
- <label for="el_license_key"><?php _e("Enter License code",$this->slug);?></label>
221
- <input type="text" class="regular-text code" name="el_license_key" size="50" placeholder="xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx" required="required">
222
- </div>
223
- <div class="el-license-field">
224
- <label for="el_license_key"><?php _e("Email Address",$this->slug);?></label>
225
- <?php
226
- $purchaseEmail = get_option( "LocoAutomaticTranslateAddonPro_lic_email", get_bloginfo( 'admin_email' ));
227
- ?>
228
- <input type="text" class="regular-text code" name="el_license_email" size="50" value="<?php echo sanitize_email($purchaseEmail); ?>" placeholder="" required="required">
229
- <div><small><?php _e("✅ I agree to share my purchase code and email for plugin verification and to receive future updates notifications!",$this->slug);?></small></div>
230
- </div>
231
- <div class="el-license-active-btn">
232
- <?php wp_nonce_field( 'el-license' ); ?>
233
- <?php submit_button('Activate'); ?>
234
- </div>
235
- <!--Enter License Key Here END-->
236
- <h3>Compare Free vs Pro (<a href='https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Premium License Key</a>)</h3>
237
- <table class="loco-addon-license">
238
-
239
- <tr>
240
- <th>Features</th>
241
- <th>Free License</th>
242
- <th>Premium License</th>
243
- </tr>
244
 
245
- <tr>
246
- <td>Yandex Translate Widget Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-yandex.png' ?>"/></td>
247
- <td><span style="color:green;font-size:1.4em;">✔</span> Available</td>
248
- <td><span style="color:green;font-size:1.4em;">✔</span> Available</td>
249
- </tr>
250
 
251
- <tr>
252
- <td>Unlimited Translations</td>
253
- <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Via Yandex Only)</span></td>
254
- <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Via Yandex, Google & DeepL)</td>
255
- </tr>
256
 
257
- <tr>
258
- <td>No API Key Required</td>
259
- <td><span style="color:green;font-size:1.4em;">✔</span> API Not Required<br/><span style="font-size:11px;font-weight:bold;">(Only Yandex Support)</span></td>
260
- <td><span style="color:green;font-size:1.4em;">✔</span> API Not Required<br/><span style="font-size:11px;font-weight:bold;">(Yandex, Google & DeepL Support)</span></td>
261
- </tr>
262
 
263
- <tr style="background:#fffb7a;font-weight: bold;">
264
- <td>Google Translate Widget Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-google.png' ?>"/></td>
265
- <td>❌ Not Available</td>
266
- <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Better than Yandex)</span></td>
267
- </tr>
268
 
269
- <tr style="background:#fffb7a;font-weight: bold;">
270
- <td>DeepL Doc Translator Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-deepl.png' ?>"/></td>
271
- <td>❌ Not Available</td>
272
- <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Limited Free Docs Translations / Day)</span></td>
273
- </tr>
274
 
275
- <tr>
276
- <td><strong>Reset Translations</strong></td>
277
- <td>❌ Not Available</td>
278
- <td><span style="color:green;font-size:1.4em;">✔</span> Available</td>
279
- </tr>
280
 
281
- <tr>
282
- <td><strong>Premium Support</strong></td>
283
- <td>❌ Not Available<br/><strong>(Support Time: 7 – 10 days)</strong></td>
284
- <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><strong>(Support Time: 24 - 48 Hrs)</strong></td>
285
- </tr>
286
-
287
- </table>
288
- <div>
289
- <strong style="color:#e00b0b;">*Important Points</strong>
290
- <ol>
291
- <li>DeepL Translate provides better translations than Google, Yandex or other machine translation providers.<br/><a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank"><b>Read review by Techcrunch!</b></a></li>
292
- <li>Currently DeepL Doc Translator provides limited number of free docs translations per day.<br/>You can purchase to <a href="https://www.deepl.com/pro?cta=homepage-free-trial#pricing" target="_blank">DeepL Pro</a> to increase this limit.</li>
293
- <li>Currently automatic translate providers do not support HTML and special characters translations.<br/>So plugin will not translate any string that contains HTML or special characters.</li>
294
- <li>If any auto-translation provider stops any of its free translation service then plugin will not<br/>support that translation service provider.</li>
295
- </ol>
296
  </div>
297
- <br/>
298
- <a class="button button-primary" href='https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Premium License Key</a>
299
  </div>
300
  </form>
301
  <?php
136
  <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
137
  <input type="hidden" name="action" value="LocoAutomaticTranslateAddonPro_el_deactivate_license"/>
138
  <div class="el-license-container">
139
+ <h3 class="el-license-title"><i class="dashicons-before dashicons-translation"></i> <?php _e("Automatic Translate Addon For Loco Translate - Premium License Status",$this->slug);?> </h3>
140
+ <div class="el-license-content">
141
+ <div class="el-license-form">
142
+ <h3>Active License Status</h3>
143
+ <ul class="el-license-info">
144
+ <li>
145
+ <div>
146
+ <span class="el-license-info-title"><?php _e("License Status",$this->slug);?></span>
147
 
148
+ <?php if ( $this->responseObj->is_valid ) : ?>
149
+ <span class="el-license-valid"><?php _e("Valid",$this->slug);?></span>
150
+ <?php else : ?>
151
+ <span class="el-license-valid"><?php _e("Invalid",$this->slug);?></span>
152
+ <?php endif; ?>
153
+ </div>
154
+ </li>
155
 
156
+ <li>
157
+ <div>
158
+ <span class="el-license-info-title"><?php _e("License Type",$this->slug);?></span>
159
+ <?php echo $this->responseObj->license_title; ?>
160
+ </div>
161
+ </li>
162
 
163
+ <li>
164
+ <div>
165
+ <span class="el-license-info-title"><?php _e("License Expiry Date",$this->slug);?></span>
166
+ <?php echo $this->responseObj->expire_date; ?>
167
+ </div>
168
+ </li>
169
 
170
+ <li>
171
+ <div>
172
+ <span class="el-license-info-title"><?php _e("Support Expiry Date",$this->slug);?></span>
173
+ <?php echo $this->responseObj->support_end; ?>
174
+ </div>
175
+ </li>
176
+ <li>
177
+ <div>
178
+ <span class="el-license-info-title"><?php _e("Your License Key",$this->slug);?></span>
179
+ <span class="el-license-key"><?php echo esc_attr( substr($this->responseObj->license_key,0,9)."XXXXXXXX-XXXXXXXX".substr($this->responseObj->license_key,-9) ); ?></span>
180
+ </div>
181
+ </li>
182
+ </ul>
183
+ <div class="el-license-active-btn">
184
+ <?php wp_nonce_field( 'el-license' ); ?>
185
+ <?php submit_button('Deactivate License'); ?>
186
  </div>
187
+ </div>
188
+ <div class="el-license-textbox">
189
+ <h3>Important Points</h3>
190
+ <ol>
191
+ <li>Please deactivate your license first before moving your website or changing domain.</li>
192
+ <li>Plugin does not auto-translate any string that contains HTML and special characters.</li>
193
+ <li>Currently DeepL Doc Translator provides limited number of free docs translations per day. You can purchase to <a href="https://www.deepl.com/pro?cta=homepage-free-trial#pricing" target="_blank">DeepL Pro</a> to increase this limit.</li>
194
+ <li>If you have any issue or query, please <a href="https://locoaddon.com/support/" target="_blank">contact support</a>.</li>
195
+ </ol>
196
+ <div class="el-pluginby">
197
+ Plugin by<br/>
198
+ <a href="https://coolplugins.net" target="_blank"><img src="<?php echo ATLT_URL.'/assets/images/coolplugins-logo.png' ?>"/></a>
199
+ </div>
200
+ </div>
201
  </div>
202
  </div>
203
  </form>
209
  <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
210
  <input type="hidden" name="action" value="LocoAutomaticTranslateAddonPro_el_activate_license"/>
211
  <div class="el-license-container">
212
+ <h3 class="el-license-title"><i class="dashicons-before dashicons-translation"></i> <?php _e("Automatic Translate Addon For Loco Translate - Premium License",$this->slug);?></h3>
213
+ <div class="el-license-content">
214
+ <div class="el-license-form">
215
+ <h3>Activate Premium License</h3>
216
+ <?php
217
+ if(!empty($this->showMessage) && !empty($this->licenseMessage)){
218
+ ?>
219
+ <div class="notice notice-error is-dismissible">
220
+ <p><?php echo _e($this->licenseMessage,$this->slug); ?></p>
221
+ </div>
222
+ <?php
223
+ }
224
+ ?>
225
+ <!--Enter License Key Here START-->
226
+ <div class="el-license-field">
227
+ <label for="el_license_key"><?php _e("Enter License code",$this->slug);?></label>
228
+ <input type="text" class="regular-text code" name="el_license_key" size="50" placeholder="xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxxxx" required="required">
229
+ </div>
230
+ <div class="el-license-field">
231
+ <label for="el_license_key"><?php _e("Email Address",$this->slug);?></label>
232
+ <?php
233
+ $purchaseEmail = get_option( "LocoAutomaticTranslateAddonPro_lic_email", get_bloginfo( 'admin_email' ));
234
+ ?>
235
+ <input type="text" class="regular-text code" name="el_license_email" size="50" value="<?php echo sanitize_email($purchaseEmail); ?>" placeholder="" required="required">
236
+ <div><small><?php _e("✅ I agree to share my purchase code and email for plugin verification and to receive future updates notifications!",$this->slug);?></small></div>
237
+ </div>
238
+ <div class="el-license-active-btn">
239
+ <?php wp_nonce_field( 'el-license' ); ?>
240
+ <?php submit_button('Activate'); ?>
241
+ </div>
242
+ <!--Enter License Key Here END-->
243
+ <div>
244
+ <strong style="color:#e00b0b;">*Important Points</strong>
245
+ <ol>
246
+ <li>DeepL Translate provides better translations than Google, Yandex or other machine translation providers. <a href="https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/" target="_blank"><b>Read review by Techcrunch!</b></a></li>
247
+ <li>Currently DeepL Doc Translator provides limited number of free docs translations per day. You can purchase to <a href="https://www.deepl.com/pro?cta=homepage-free-trial#pricing" target="_blank">DeepL Pro</a> to increase this limit.</li>
248
+ <li>Automatic translate providers do not support HTML and special characters translations. So plugin will not translate any string that contains HTML or special characters.</li>
249
+ <li>If any auto-translation provider stops any of its free translation service then plugin will not support that translation service provider.</li>
250
+ </ol>
251
+ </div>
252
+ <br/>
253
+ <a class="button button-primary" href='https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Pro Plugin + License</a>
254
  </div>
255
+
256
+ <div class="el-license-textbox">
257
+ <h3>Compare Free vs Pro (<a href='https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing' target='_blank'>Buy Pro Plugin + License</a>)</h3>
258
+ <table class="loco-addon-license">
259
+
260
+ <tr>
261
+ <th>Features</th>
262
+ <th>Free License</th>
263
+ <th>Premium License</th>
264
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
+ <tr>
267
+ <td>Yandex Translate Widget Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-yandex.png' ?>"/></td>
268
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available</td>
269
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available</td>
270
+ </tr>
271
 
272
+ <tr>
273
+ <td>Unlimited Translations</td>
274
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Via Yandex Only)</span></td>
275
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Via Yandex, Google & DeepL)</td>
276
+ </tr>
277
 
278
+ <tr>
279
+ <td>No API Key Required</td>
280
+ <td><span style="color:green;font-size:1.4em;">✔</span> API Not Required<br/><span style="font-size:11px;font-weight:bold;">(Only Yandex Support)</span></td>
281
+ <td><span style="color:green;font-size:1.4em;">✔</span> API Not Required<br/><span style="font-size:11px;font-weight:bold;">(Yandex, Google & DeepL Support)</span></td>
282
+ </tr>
283
 
284
+ <tr style="background:#fffb7a;font-weight: bold;">
285
+ <td>Google Translate Widget Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-google.png' ?>"/></td>
286
+ <td>❌ Not Available</td>
287
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Better than Yandex)</span></td>
288
+ </tr>
289
 
290
+ <tr style="background:#fffb7a;font-weight: bold;">
291
+ <td>DeepL Doc Translator Support<br/><img style="border: 1px solid;" src="<?php echo ATLT_URL.'/assets/images/powered-by-deepl.png' ?>"/></td>
292
+ <td>❌ Not Available</td>
293
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><span style="font-size:11px;font-weight:bold;">(Limited Free Docs Translations / Day)</span></td>
294
+ </tr>
295
 
296
+ <tr>
297
+ <td><strong>Premium Support</strong></td>
298
+ <td>❌ Not Available<br/><strong>(Support Time: 7 – 10 days)</strong></td>
299
+ <td><span style="color:green;font-size:1.4em;">✔</span> Available<br/><strong>(Support Time: 24 - 48 Hrs)</strong></td>
300
+ </tr>
301
 
302
+ </table>
303
+ <div class="el-pluginby">
304
+ Plugin by<br/>
305
+ <a href="https://coolplugins.net" target="_blank"><img src="<?php echo ATLT_URL.'/assets/images/coolplugins-logo.png' ?>"/></a>
306
+ </div>
307
+ </div>
 
 
 
 
 
 
 
 
 
308
  </div>
 
 
309
  </div>
310
  </form>
311
  <?php
includes/Register/style.css CHANGED
@@ -1,11 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .el-license-container .el-license-field {
2
  display: block;
3
  margin-bottom: 15px;
4
  }
5
 
6
  .el-license-container .el-license-field input {
7
- font-size: 200%;
8
  padding: 8px 10px 10px;
 
9
  }
10
 
11
  .el-license-container .el-license-field label {
@@ -17,13 +72,6 @@
17
  margin-top: 25px;
18
  }
19
 
20
- .el-license-container {
21
- margin-top: 20px;
22
- padding: 35px;
23
- background: #fff;
24
- border-radius: 4px;
25
- }
26
-
27
  .el-license-container .notice-error,
28
  .el-license-container div.error {
29
  background: rgba(220, 50, 50, 0.11);
@@ -80,4 +128,48 @@ div#activating-loco-pro-response {
80
  font-size: 21px;
81
  background: #f5f5f5;
82
  padding: 45px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
1
+ .el-license-container {
2
+ margin-top: 20px;
3
+ padding: 0;
4
+ display: inline-block;
5
+ margin: 15px auto;
6
+ box-sizing: border-box;
7
+ width: calc(100% - 20px);
8
+ background: #fff;
9
+ border-radius: 10px;
10
+ border: 1px solid #ddd;
11
+ box-shadow: 0 0 10px -5px #afafaf;
12
+ overflow: hidden;
13
+ position: relative;
14
+ }
15
+
16
+ .el-license-container * {
17
+ box-sizing: border-box;
18
+ }
19
+
20
+ .el-license-container h3.el-license-title {
21
+ background-color: #5cb85c;
22
+ background: linear-gradient(to right, #5cb85c, #1f9e5e);
23
+ padding: 20px 10px;
24
+ margin: 0;
25
+ display: inline-block;
26
+ width: 100%;
27
+ color: #fff;
28
+ font-size: 22px;
29
+ line-height: 22px;
30
+ }
31
+
32
+ .el-license-container .el-license-content {
33
+ padding: 25px;
34
+ width: 100%;
35
+ display: inline-block;
36
+ }
37
+
38
+ .el-license-form,
39
+ .el-license-textbox {
40
+ display: inline-block;
41
+ width: calc(50% - 5px);
42
+ vertical-align: top;
43
+ }
44
+
45
+ .el-license-form {
46
+ padding-right: 40px;
47
+ }
48
+
49
+ .el-license-textbox ol {
50
+ border: 3px solid #5ab75c;
51
+ padding: 5px 20px;
52
+ margin-left: 0;
53
+ }
54
+
55
  .el-license-container .el-license-field {
56
  display: block;
57
  margin-bottom: 15px;
58
  }
59
 
60
  .el-license-container .el-license-field input {
61
+ font-size: 150%;
62
  padding: 8px 10px 10px;
63
+ width: 100%;
64
  }
65
 
66
  .el-license-container .el-license-field label {
72
  margin-top: 25px;
73
  }
74
 
 
 
 
 
 
 
 
75
  .el-license-container .notice-error,
76
  .el-license-container div.error {
77
  background: rgba(220, 50, 50, 0.11);
128
  font-size: 21px;
129
  background: #f5f5f5;
130
  padding: 45px;
131
+ }
132
+
133
+ table.loco-addon-license {
134
+ width: 100%;
135
+ table-layout: fixed !IMPORTANT;
136
+ }
137
+
138
+ table.loco-addon-license tr th,
139
+ table.loco-addon-license tr td {
140
+ border: 1px solid #bbb;
141
+ padding: 12px;
142
+ text-align: center;
143
+ width: 33%;
144
+ }
145
+
146
+ table.loco-addon-license img {
147
+ max-width: 100%;
148
+ }
149
+
150
+ table.loco-addon-license tr td strong img {
151
+ height: 28px;
152
+ width: auto;
153
+ vertical-align: middle;
154
+ }
155
+
156
+ .el-pluginby {
157
+ width: 100%;
158
+ display: block;
159
+ text-align: right;
160
+ font-style: italic;
161
+ }
162
+
163
+ .el-pluginby img {
164
+ max-width: 100px;
165
+ }
166
+
167
+ @media only screen and (max-width: 940px) {
168
+ .el-license-form,
169
+ .el-license-textbox {
170
+ width: 100%;
171
+ }
172
+ .el-license-form {
173
+ padding-right: 0;
174
+ }
175
  }
includes/translator.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter('loco_api_translate_loco_auto','loco_auto_translator_process_batch',0,3);
4
+ /**
5
+ * Hook fired as a filter for the "loco_auto" translation api
6
+ * @param string[] input strings
7
+ * @param Loco_Locale target locale for translations
8
+ * @param array our own api configuration
9
+ * @return string[] output strings
10
+ */
11
+
12
+ function loco_auto_translator_process_batch( array $sources, Loco_Locale $Locale, array $config ){
13
+ $targets = array();
14
+ $url_data=parse_query($_SERVER['HTTP_REFERER']);
15
+ if(isset($url_data['domain'])&& !empty($url_data['domain']))
16
+ {
17
+ $domain=$url_data['domain'];
18
+ }else{
19
+ $domain='temp';
20
+ }
21
+ $lang = $Locale->lang;
22
+ $region = $Locale->region;
23
+ $project_id=$domain.'-'.$lang.'_'.$region;
24
+ $totalStrings=count($sources);
25
+
26
+ $first_part= get_transient($project_id.'-first');
27
+
28
+
29
+ $second_part=get_transient($project_id.'-second');
30
+ $third_part= get_transient($project_id.'-third');
31
+
32
+ if(!empty($first_part) && !empty($second_part) && !empty($third_part)){
33
+ $allString = array_merge($first_part,$second_part,$third_part);
34
+ }
35
+ elseif(!empty($first_part) && !empty($second_part)){
36
+ $allString = array_merge($first_part,$second_part);
37
+ }
38
+ else{
39
+ $allString = get_transient($project_id);
40
+ }
41
+
42
+
43
+ if($allString!==false){
44
+ foreach( $sources as $i => $source ){
45
+ $index = array_search($source, array_column($allString, 'source'));
46
+ if( is_numeric($index)){
47
+ if(isset($allString[$index]['target']))
48
+ {
49
+ $targets[$i] =$allString[$index]['target'];
50
+ }
51
+ }else{
52
+ $targets[$i] ='';
53
+ }
54
+ }
55
+ return $targets;
56
+ }else{
57
+ throw new Loco_error_Exception('Please translate strings using Auto Translate addon button first.');
58
+ }
59
+ }
60
+
61
+
62
+
63
+
64
+ function parse_query($var)
65
+ {
66
+ /**
67
+ * Use this function to parse out the query array element from
68
+ * the output of parse_url().
69
+ */
70
+ $var = parse_url($var, PHP_URL_QUERY);
71
+ $var = html_entity_decode($var);
72
+ $var = explode('&', $var);
73
+ $arr = array();
74
+
75
+ foreach($var as $val)
76
+ {
77
+ $x = explode('=', $val);
78
+ $arr[$x[0]] = $x[1];
79
+ }
80
+ unset($val, $x, $var);
81
+ return $arr;
82
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: narinder-singh, satindersingh
3
  Donate link: https://paypal.me/CoolPlugins/10USD/
4
  Tags: translate, translation, translator, localization, language, translations, loco, loco translate, loco addon, google translate, deepl
5
  Requires at least: 4.5
6
- Tested up to: 5.5
7
  Requires PHP: 5.6
8
  Stable tag: trunk
9
  License: GPLv2 or later
@@ -13,17 +13,17 @@ Automatic language translator add-on for Loco Translate official plugin to trans
13
 
14
  == Description ==
15
 
16
- > **Important Notice:-** This addon is currently only compatible with Loco Translate official plugin latest version(2.4.0). We are working on an update to make this addon compatible with all future updates of Loco Translate official plugin without any conflict, it will available soon.
17
 
18
  ### 🐦 Automatic Machine Translator Addon For Loco
19
 
20
- Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)**(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
  ### 🤖 No Translate API Required! + Unlimited Translations!
23
 
24
  * Yes, it's true, there is no requirement to use any translate API key to use this addon for automatic translations, just install it and translate unlimited characters with one click.
25
  * Free version of this addon supports **[Yandex Page Translate Widget](https://translate.yandex.com/developers/website-widget)**. By using this translate widget you can unlimited translate any plugin or theme translatable plain text strings.
26
- * Pro version provides support for Google Translate widget and DeepL Doc Translator. You can also use them without any API key unlimited times. DeepL Translate is better than Google, Yandex or any other machine translation service provider - **[read review by TechCrunch](https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/)**
27
 
28
  ### ⚡ Loco Addon Features
29
 
@@ -42,7 +42,6 @@ Install this plugin along with the famous **[Loco Translate](https://wordpress.o
42
  * ✅ **API Key Required:** Not Required (Yandex Widget Support)
43
  * ❌ **Google Translate Widget Support:** Not Available
44
  * ❌ **DeepL Doc Translator Support:** Not Available
45
- * ❌ **Reset Translations:** Not Available
46
  * ❌ **Premium Support:** Not Available
47
 
48
  **Premium License**
@@ -54,19 +53,18 @@ Install this plugin along with the famous **[Loco Translate](https://wordpress.o
54
  (Yandex, Google & DeepL Support)
55
  * ✅ **Google Translate Widget Support:** Available
56
  * ✅ **DeepL Doc Translator Support:** Available
57
- (limited free docs translations / day or purchase DeepL Pro)
58
- * ✅ **Reset Translations:** Available
59
  * ✅ **Premium Support:** Quick Email Support
60
  (contact@coolplugins.net -**Support time:- 24-48 hours**)
61
  * **Buy Premium License:** [$18 - $88 🛒](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing)
62
 
63
- > DeepL Doc Translator has limitations for number of docs translations per day free of cost, you can purchase their pro license to increase this limit.
64
 
65
  **❗ Important Notice:** This addon only provides settings to use third party auto-translation widgets and services(Yandex, Google, DeepL etc.), it does not provide any translation service. So we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site. If any auto-translate provider stops providing auto-translation widget or service in future, in that case plugin will not support that translation provider.
66
 
67
- **🎬 Unlimited Translations(no API) - Pro Version Video**
68
 
69
- https://youtu.be/RkVwHB3hppo
70
 
71
  > “Many people make the mistake of saving money by wasting time.”
72
 
@@ -85,7 +83,7 @@ We(**CoolPlugins.net**) only manage [locoaddon.com](https://locoaddon.com) (**ad
85
 
86
  ### ✍ Special THANKS!
87
 
88
- Special thanks to famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin author **Tim Whitlock** 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 a translate widget for websites.
89
 
90
  All automatic translations will machine translations, powered by third party auto-translate providers(Google, Yandex or DeepL), so we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site.
91
 
@@ -123,7 +121,7 @@ There is no limit. Yes, you can translate unlimited characters without any API k
123
 
124
  **Free license** users:- can translate unlimited characters only via Yandex Page Translate Widget.
125
 
126
- **Premium license** users:- can also use Google Page Translate Widget & DeepL Doc Translator for unlimited translations.
127
 
128
  > This addon only provides an interface to use third party translation widgets and services, it do not provide any translation service. Any auto-translate provider can stop providing free translation widget or service anytime in future, in that case plugin will not support that auto-translate provider.
129
 
@@ -136,7 +134,14 @@ There is no limit. Yes, you can translate unlimited characters without any API k
136
  5. Premium License Pricing
137
 
138
  == Changelog ==
139
-
 
 
 
 
 
 
 
140
  <strong>Version 2.0.1 | 07 AUG 2020</strong>
141
  <pre>
142
  Notice Added: Addon is currently compatible with only Loco Translate official plugin version 2.4.0, new compatible update will available soon.
3
  Donate link: https://paypal.me/CoolPlugins/10USD/
4
  Tags: translate, translation, translator, localization, language, translations, loco, loco translate, loco addon, google translate, deepl
5
  Requires at least: 4.5
6
+ Tested up to: 5.5.1
7
  Requires PHP: 5.6
8
  Stable tag: trunk
9
  License: GPLv2 or later
13
 
14
  == Description ==
15
 
16
+ > **Important Notice:-** This plugin works as an auto-translate addon for Loco Translate official plugin latest version(2.4.3 or higher).
17
 
18
  ### 🐦 Automatic Machine Translator Addon For Loco
19
 
20
+ Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin (**1,000,000+ Active Installations**) and automatically machine translate any WordPress plugin or theme translation files into any language.
21
 
22
  ### 🤖 No Translate API Required! + Unlimited Translations!
23
 
24
  * Yes, it's true, there is no requirement to use any translate API key to use this addon for automatic translations, just install it and translate unlimited characters with one click.
25
  * Free version of this addon supports **[Yandex Page Translate Widget](https://translate.yandex.com/developers/website-widget)**. By using this translate widget you can unlimited translate any plugin or theme translatable plain text strings.
26
+ * Pro version provides support for Google Translate widget and DeepL Doc Translator. You can also use them without any API key unlimited times. DeepL Translate provides limited number of free doc translations daily. It is better than Google, Yandex or any other machine translation service provider - **[read review by TechCrunch](https://techcrunch.com/2017/08/29/deepl-schools-other-online-translators-with-clever-machine-learning/)**
27
 
28
  ### ⚡ Loco Addon Features
29
 
42
  * ✅ **API Key Required:** Not Required (Yandex Widget Support)
43
  * ❌ **Google Translate Widget Support:** Not Available
44
  * ❌ **DeepL Doc Translator Support:** Not Available
 
45
  * ❌ **Premium Support:** Not Available
46
 
47
  **Premium License**
53
  (Yandex, Google & DeepL Support)
54
  * ✅ **Google Translate Widget Support:** Available
55
  * ✅ **DeepL Doc Translator Support:** Available
56
+ (Limited free docs translations / day or purchase DeepL Pro)
 
57
  * ✅ **Premium Support:** Quick Email Support
58
  (contact@coolplugins.net -**Support time:- 24-48 hours**)
59
  * **Buy Premium License:** [$18 - $88 🛒](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing)
60
 
61
+ > DeepL Doc Translator provides limited number of free docs translations per day, you can purchase their pro license to increase this limit.
62
 
63
  **❗ Important Notice:** This addon only provides settings to use third party auto-translation widgets and services(Yandex, Google, DeepL etc.), it does not provide any translation service. So we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site. If any auto-translate provider stops providing auto-translation widget or service in future, in that case plugin will not support that translation provider.
64
 
65
+ **🎬 Unlimited Translations(no API)**
66
 
67
+ https://youtu.be/UdT6lRg_IHA
68
 
69
  > “Many people make the mistake of saving money by wasting time.”
70
 
83
 
84
  ### ✍ Special THANKS!
85
 
86
+ Special thanks to famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin author **Tim Whitlock** for creating an awesome plugin for translations and also thanks to Yandex for providing a translate widget for websites.
87
 
88
  All automatic translations will machine translations, powered by third party auto-translate providers(Google, Yandex or DeepL), so we don't guarantee 100% correctness, please check all translated text carefully before making it live on your production site.
89
 
121
 
122
  **Free license** users:- can translate unlimited characters only via Yandex Page Translate Widget.
123
 
124
+ **Premium license** users:- can also use Google Page Translate Widget & DeepL Doc Translator for unlimited translations. DeepL Doc Translator provides limited number of free docs translations per day, you can purchase their pro license to increase this limit.
125
 
126
  > This addon only provides an interface to use third party translation widgets and services, it do not provide any translation service. Any auto-translate provider can stop providing free translation widget or service anytime in future, in that case plugin will not support that auto-translate provider.
127
 
134
  5. Premium License Pricing
135
 
136
  == Changelog ==
137
+ <strong>Version 2.1 | 14 OCT 2020</strong>
138
+ <pre>
139
+ Added: integrated new Auto Translation
140
+ Added: Added support for Loco Translate Latest version
141
+ Fixed: compatibility issues with Loco Translate
142
+ Improved: removed Extra Code
143
+ Improved: improved custom.js
144
+ </pre>
145
  <strong>Version 2.0.1 | 07 AUG 2020</strong>
146
  <pre>
147
  Notice Added: Addon is currently compatible with only Loco Translate official plugin version 2.4.0, new compatible update will available soon.