Version Description
Download this release
Release Info
Developer | Narinder singh |
Plugin | Automatic Translate Addon For Loco Translate |
Version | 2.2.3 |
Comparing to | |
See all releases |
Code changes from version 2.1.3 to 2.2.3
- assets/js/widget.js +90 -97
- automatic-translator-addon-for-loco-translate.php +4 -4
- readme.txt +20 -2
assets/js/widget.js
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
-
|
2 |
-
(function ($,win, doc, nav, params, namespace, undefined) {
|
3 |
'use strict';
|
4 |
|
5 |
var util = {
|
6 |
keycode: {
|
7 |
ESCAPE: 27
|
8 |
},
|
9 |
-
getRequest: function
|
10 |
if (win.XDomainRequest) {
|
11 |
return new win.XDomainRequest();
|
12 |
}
|
@@ -15,7 +14,7 @@
|
|
15 |
}
|
16 |
return null;
|
17 |
},
|
18 |
-
loadScript: function
|
19 |
var script = doc.createElement('script');
|
20 |
script.src = src;
|
21 |
|
@@ -26,52 +25,53 @@
|
|
26 |
|
27 |
parent.appendChild(script);
|
28 |
},
|
29 |
-
loadResource: function
|
30 |
var request = this.getRequest();
|
31 |
|
32 |
if (!request) {
|
33 |
return null;
|
34 |
}
|
35 |
|
36 |
-
request.onload = function
|
37 |
callback(this.responseText);
|
38 |
};
|
39 |
request.open('GET', url, true);
|
40 |
|
41 |
-
win.setTimeout(function
|
42 |
request.send();
|
43 |
}, 0);
|
44 |
|
45 |
return request;
|
46 |
},
|
47 |
-
getStyleList: function
|
48 |
var value = element.getAttribute('class');
|
49 |
if (!value) {
|
50 |
return [];
|
51 |
}
|
52 |
return value.replace(/\s+/g, ' ').trim().split(' ');
|
53 |
},
|
54 |
-
hasStyleName: function
|
55 |
var list = this.getStyleList(element);
|
56 |
return !!list.length && list.indexOf(name) >= 0;
|
57 |
},
|
58 |
-
addStyleName: function
|
59 |
var list = this.getStyleList(element);
|
60 |
list.push(name);
|
61 |
element.setAttribute('class', list.join(' '));
|
62 |
},
|
63 |
-
removeStyleName: function
|
64 |
-
var list = this.getStyleList(element),
|
|
|
65 |
if (index >= 0) {
|
66 |
list.splice(index, 1);
|
67 |
element.setAttribute('class', list.join(' '));
|
68 |
}
|
69 |
},
|
70 |
-
isSupportedBrowser: function
|
71 |
return 'localStorage' in win &&
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
}
|
76 |
};
|
77 |
|
@@ -80,7 +80,7 @@
|
|
80 |
var Button = function Button(element, contentElement) {
|
81 |
var self = this;
|
82 |
|
83 |
-
element.addEventListener('click', function
|
84 |
self.onClick(event);
|
85 |
}, false);
|
86 |
|
@@ -88,9 +88,9 @@
|
|
88 |
this._contentElement = contentElement || this._element;
|
89 |
};
|
90 |
|
91 |
-
Button.prototype.onClick = function
|
92 |
|
93 |
-
Button.prototype.setText = function
|
94 |
this._contentElement.textContent = text;
|
95 |
return this;
|
96 |
};
|
@@ -102,14 +102,14 @@
|
|
102 |
|
103 |
form.reset();
|
104 |
|
105 |
-
form.addEventListener('click', function
|
106 |
var target = event.target;
|
107 |
if ('value' in target) {
|
108 |
self.onSelect(target.value);
|
109 |
}
|
110 |
}, false);
|
111 |
|
112 |
-
form.addEventListener('change', function
|
113 |
alert("form change state");
|
114 |
var target = event.target;
|
115 |
if (target.checked) {
|
@@ -121,19 +121,19 @@
|
|
121 |
this._itemName = itemName;
|
122 |
};
|
123 |
|
124 |
-
Select.prototype.onSelect = function
|
125 |
|
126 |
-
Select.prototype.onChange = function
|
127 |
|
128 |
-
Select.prototype.isHidden = function
|
129 |
return this._form.hasAttribute('hidden');
|
130 |
};
|
131 |
|
132 |
-
Select.prototype.getItems = function
|
133 |
return this._form[this._itemName] || [];
|
134 |
};
|
135 |
|
136 |
-
Select.prototype.getValue = function
|
137 |
var i, n, items = this.getItems();
|
138 |
for (i = 0, n = items.length; i < n; i++) {
|
139 |
if (items[i].checked) {
|
@@ -143,7 +143,7 @@
|
|
143 |
return '';
|
144 |
};
|
145 |
|
146 |
-
Select.prototype.setValue = function
|
147 |
var i, n, items = this.getItems();
|
148 |
if (value === this.getValue()) {
|
149 |
return this;
|
@@ -158,7 +158,7 @@
|
|
158 |
return this;
|
159 |
};
|
160 |
|
161 |
-
Select.prototype.setHidden = function
|
162 |
hidden = !!hidden;
|
163 |
if (hidden !== this.isHidden()) {
|
164 |
this._form[(hidden ? 'set' : 'remove') + 'Attribute']('hidden', '');
|
@@ -167,7 +167,7 @@
|
|
167 |
return this;
|
168 |
};
|
169 |
|
170 |
-
Select.prototype.onHiddenChange = function
|
171 |
|
172 |
// Widget
|
173 |
|
@@ -190,28 +190,29 @@
|
|
190 |
this._pageLang = pageLang;
|
191 |
this._translator = translator;
|
192 |
|
193 |
-
this.onStateChange = function
|
194 |
if (name === 'active') {
|
195 |
storage.setValue('active', enable);
|
196 |
}
|
197 |
};
|
198 |
|
199 |
-
select.onSelect = function
|
200 |
this.setHidden(true);
|
201 |
self.translate(lang);
|
202 |
updatePopupSettings();
|
203 |
};
|
204 |
|
205 |
-
select.onChange = function
|
206 |
-
|
207 |
storage.setValue('lang', lang);
|
208 |
rightButton.setText(lang);
|
209 |
self.setState('invalid', lang === pageLang);
|
210 |
-
|
211 |
};
|
212 |
|
213 |
-
select.onHiddenChange = function
|
214 |
-
var docElem = doc.documentElement,
|
|
|
215 |
self.setState('expanded', !hidden);
|
216 |
if (!hidden) {
|
217 |
self.setState('right', false)
|
@@ -229,11 +230,11 @@
|
|
229 |
}
|
230 |
};
|
231 |
|
232 |
-
element.addEventListener('blur', function
|
233 |
select.setHidden(true);
|
234 |
}, false);
|
235 |
|
236 |
-
element.addEventListener('keydown', function
|
237 |
switch (event.keyCode) {
|
238 |
case util.keycode.ESCAPE:
|
239 |
select.setHidden(true);
|
@@ -241,13 +242,13 @@
|
|
241 |
}
|
242 |
}, false);
|
243 |
|
244 |
-
translator.on('error', function
|
245 |
this.abort();
|
246 |
self.setState('busy', false)
|
247 |
.setState('error', true);
|
248 |
});
|
249 |
|
250 |
-
translator.on('progress', function
|
251 |
switch (progress) {
|
252 |
case 0:
|
253 |
self.setState('busy', true)
|
@@ -262,27 +263,26 @@
|
|
262 |
});
|
263 |
|
264 |
// custom code
|
265 |
-
function updatePopupSettings(){
|
266 |
-
var container
|
267 |
container.find(".string_container").scrollTop(0);
|
268 |
-
var scrollHeight=
|
269 |
-
var scrollSpeed=800;
|
270 |
-
if(scrollHeight > scrollSpeed){
|
271 |
scrollSpeed = scrollHeight;
|
272 |
}
|
273 |
-
if(scrollHeight!==undefined && scrollHeight>100)
|
274 |
-
|
275 |
-
container.find(".my_translate_progress").fadeIn("slow");
|
276 |
setTimeout(() => {
|
277 |
-
container.find(".string_container").animate({
|
278 |
-
scrollTop:scrollHeight+2000
|
279 |
-
},scrollSpeed*2,'linear');
|
280 |
}, 1000);
|
281 |
-
|
282 |
container.find('.string_container').on('scroll', function() {
|
283 |
-
if($(this).scrollTop() + $(this).innerHeight() + 50 >= $(this)[0].scrollHeight) {
|
284 |
setTimeout(() => {
|
285 |
-
container.find(".save_it").prop("disabled",false);
|
286 |
container.find(".ytstats").fadeIn("slow");
|
287 |
container.find(".my_translate_progress").fadeOut("slow");
|
288 |
container.find(".string_container").stop();
|
@@ -290,32 +290,31 @@
|
|
290 |
}, 1500);
|
291 |
}
|
292 |
});
|
293 |
-
|
294 |
-
if(
|
295 |
setTimeout(() => {
|
296 |
-
container.find(".save_it").prop("disabled",false);
|
297 |
container.find(".ytstats").fadeIn("slow");
|
298 |
container.find(".my_translate_progress").fadeOut("slow");
|
299 |
container.find(".string_container").stop();
|
300 |
$('body').css('top', '0');
|
301 |
}, 1500);
|
302 |
}
|
303 |
-
}
|
304 |
-
else{
|
305 |
setTimeout(() => {
|
306 |
-
|
307 |
-
|
308 |
}, 2000);
|
309 |
}
|
310 |
}
|
311 |
|
312 |
-
leftButton.onClick = function
|
313 |
select.setHidden(true);
|
314 |
self.translate(select.getValue());
|
315 |
updatePopupSettings();
|
316 |
};
|
317 |
|
318 |
-
rightButton.onClick = function
|
319 |
if (self.hasState('active')) {
|
320 |
translator.undo();
|
321 |
self.setState('busy', false)
|
@@ -327,26 +326,26 @@
|
|
327 |
}
|
328 |
};
|
329 |
|
330 |
-
closeButton.onClick = function
|
331 |
select.setHidden(true);
|
332 |
};
|
333 |
-
|
334 |
-
if(window.locoConf.conf!=undefined){
|
335 |
-
var defaultcode = window.locoConf.conf.locale.lang?window.locoConf.conf.locale.lang:null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
}
|
337 |
-
|
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');
|
@@ -355,11 +354,11 @@
|
|
355 |
}
|
356 |
}
|
357 |
};
|
358 |
-
Widget.prototype.hasState = function
|
359 |
return util.hasStyleName(this._element, 'yt-state_' + name);
|
360 |
};
|
361 |
|
362 |
-
Widget.prototype.setState = function
|
363 |
var hasState = this.hasState(name);
|
364 |
enable = !!enable;
|
365 |
if (enable === hasState) {
|
@@ -372,14 +371,14 @@
|
|
372 |
return this;
|
373 |
};
|
374 |
|
375 |
-
Widget.prototype.translate = function
|
376 |
if (targetLang && !this.hasState('active')) {
|
377 |
this._translator.translate(this._pageLang, targetLang);
|
378 |
}
|
379 |
return this;
|
380 |
};
|
381 |
|
382 |
-
Widget.prototype.onStateChange = function
|
383 |
|
384 |
// Storage
|
385 |
|
@@ -392,11 +391,11 @@
|
|
392 |
}
|
393 |
};
|
394 |
|
395 |
-
Storage.prototype.getValue = function
|
396 |
return this._data[prop];
|
397 |
};
|
398 |
|
399 |
-
Storage.prototype.setValue = function
|
400 |
this._data[prop] = value;
|
401 |
try {
|
402 |
win.localStorage[this._name] = win.JSON.stringify(this._data);
|
@@ -408,23 +407,19 @@
|
|
408 |
if (!wrapper || !util.isSupportedBrowser()) {
|
409 |
return;
|
410 |
}
|
411 |
-
|
412 |
-
|
413 |
-
util.loadScript('https://yastatic.net/s3/translate/v20.7.4/js/tr_page.js', wrapper, function () {
|
414 |
util.loadResource('https://translate.yandex.net/website-widget/v1/widget.html',
|
415 |
-
function
|
416 |
var element;
|
417 |
-
|
418 |
if (!responseText) {
|
419 |
return;
|
420 |
}
|
421 |
-
|
422 |
wrapper.innerHTML = responseText;
|
423 |
element = wrapper.querySelector('.yt-widget');
|
424 |
if (params.widgetTheme) {
|
425 |
element.setAttribute('data-theme', params.widgetTheme);
|
426 |
}
|
427 |
-
|
428 |
new Widget({
|
429 |
select: new Select(element.querySelector('.yt-listbox'), 'yt-lang'),
|
430 |
element: element,
|
@@ -434,8 +429,7 @@
|
|
434 |
userLang: (nav.language || nav.userLanguage || '').split('-')[0],
|
435 |
translator: new namespace.PageTranslator({
|
436 |
srv: 'tr-url-widget',
|
437 |
-
sid:'
|
438 |
-
// sid: '5eba4470.5f1ec29a.43208802.74722d75726c2d776964676574',
|
439 |
url: 'https://translate.yandex.net/api/v1/tr.json/translate',
|
440 |
autoSync: true,
|
441 |
maxPortionLength: 600
|
@@ -451,10 +445,9 @@
|
|
451 |
);
|
452 |
});
|
453 |
};
|
454 |
-
|
455 |
if (doc.readyState === 'complete' || doc.readyState === 'interactive') {
|
456 |
initWidget();
|
457 |
} else {
|
458 |
doc.addEventListener('DOMContentLoaded', initWidget, false);
|
459 |
}
|
460 |
-
})(jQuery,this, this.document, this.navigator, {"
|
1 |
+
(function($, win, doc, nav, params, namespace, undefined) {
|
|
|
2 |
'use strict';
|
3 |
|
4 |
var util = {
|
5 |
keycode: {
|
6 |
ESCAPE: 27
|
7 |
},
|
8 |
+
getRequest: function() {
|
9 |
if (win.XDomainRequest) {
|
10 |
return new win.XDomainRequest();
|
11 |
}
|
14 |
}
|
15 |
return null;
|
16 |
},
|
17 |
+
loadScript: function(src, parent, callback) {
|
18 |
var script = doc.createElement('script');
|
19 |
script.src = src;
|
20 |
|
25 |
|
26 |
parent.appendChild(script);
|
27 |
},
|
28 |
+
loadResource: function(url, callback) {
|
29 |
var request = this.getRequest();
|
30 |
|
31 |
if (!request) {
|
32 |
return null;
|
33 |
}
|
34 |
|
35 |
+
request.onload = function() {
|
36 |
callback(this.responseText);
|
37 |
};
|
38 |
request.open('GET', url, true);
|
39 |
|
40 |
+
win.setTimeout(function() {
|
41 |
request.send();
|
42 |
}, 0);
|
43 |
|
44 |
return request;
|
45 |
},
|
46 |
+
getStyleList: function(element) {
|
47 |
var value = element.getAttribute('class');
|
48 |
if (!value) {
|
49 |
return [];
|
50 |
}
|
51 |
return value.replace(/\s+/g, ' ').trim().split(' ');
|
52 |
},
|
53 |
+
hasStyleName: function(element, name) {
|
54 |
var list = this.getStyleList(element);
|
55 |
return !!list.length && list.indexOf(name) >= 0;
|
56 |
},
|
57 |
+
addStyleName: function(element, name) {
|
58 |
var list = this.getStyleList(element);
|
59 |
list.push(name);
|
60 |
element.setAttribute('class', list.join(' '));
|
61 |
},
|
62 |
+
removeStyleName: function(element, name) {
|
63 |
+
var list = this.getStyleList(element),
|
64 |
+
index = list.indexOf(name);
|
65 |
if (index >= 0) {
|
66 |
list.splice(index, 1);
|
67 |
element.setAttribute('class', list.join(' '));
|
68 |
}
|
69 |
},
|
70 |
+
isSupportedBrowser: function() {
|
71 |
return 'localStorage' in win &&
|
72 |
+
'querySelector' in doc &&
|
73 |
+
'addEventListener' in win &&
|
74 |
+
'getComputedStyle' in win && doc.compatMode === 'CSS1Compat';
|
75 |
}
|
76 |
};
|
77 |
|
80 |
var Button = function Button(element, contentElement) {
|
81 |
var self = this;
|
82 |
|
83 |
+
element.addEventListener('click', function(event) {
|
84 |
self.onClick(event);
|
85 |
}, false);
|
86 |
|
88 |
this._contentElement = contentElement || this._element;
|
89 |
};
|
90 |
|
91 |
+
Button.prototype.onClick = function() {};
|
92 |
|
93 |
+
Button.prototype.setText = function(text) {
|
94 |
this._contentElement.textContent = text;
|
95 |
return this;
|
96 |
};
|
102 |
|
103 |
form.reset();
|
104 |
|
105 |
+
form.addEventListener('click', function(event) {
|
106 |
var target = event.target;
|
107 |
if ('value' in target) {
|
108 |
self.onSelect(target.value);
|
109 |
}
|
110 |
}, false);
|
111 |
|
112 |
+
form.addEventListener('change', function(event) {
|
113 |
alert("form change state");
|
114 |
var target = event.target;
|
115 |
if (target.checked) {
|
121 |
this._itemName = itemName;
|
122 |
};
|
123 |
|
124 |
+
Select.prototype.onSelect = function() {};
|
125 |
|
126 |
+
Select.prototype.onChange = function() {};
|
127 |
|
128 |
+
Select.prototype.isHidden = function() {
|
129 |
return this._form.hasAttribute('hidden');
|
130 |
};
|
131 |
|
132 |
+
Select.prototype.getItems = function() {
|
133 |
return this._form[this._itemName] || [];
|
134 |
};
|
135 |
|
136 |
+
Select.prototype.getValue = function() {
|
137 |
var i, n, items = this.getItems();
|
138 |
for (i = 0, n = items.length; i < n; i++) {
|
139 |
if (items[i].checked) {
|
143 |
return '';
|
144 |
};
|
145 |
|
146 |
+
Select.prototype.setValue = function(value) {
|
147 |
var i, n, items = this.getItems();
|
148 |
if (value === this.getValue()) {
|
149 |
return this;
|
158 |
return this;
|
159 |
};
|
160 |
|
161 |
+
Select.prototype.setHidden = function(hidden) {
|
162 |
hidden = !!hidden;
|
163 |
if (hidden !== this.isHidden()) {
|
164 |
this._form[(hidden ? 'set' : 'remove') + 'Attribute']('hidden', '');
|
167 |
return this;
|
168 |
};
|
169 |
|
170 |
+
Select.prototype.onHiddenChange = function() {};
|
171 |
|
172 |
// Widget
|
173 |
|
190 |
this._pageLang = pageLang;
|
191 |
this._translator = translator;
|
192 |
|
193 |
+
this.onStateChange = function(name, enable) {
|
194 |
if (name === 'active') {
|
195 |
storage.setValue('active', enable);
|
196 |
}
|
197 |
};
|
198 |
|
199 |
+
select.onSelect = function(lang) {
|
200 |
this.setHidden(true);
|
201 |
self.translate(lang);
|
202 |
updatePopupSettings();
|
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) {
|
214 |
+
var docElem = doc.documentElement,
|
215 |
+
formRect;
|
216 |
self.setState('expanded', !hidden);
|
217 |
if (!hidden) {
|
218 |
self.setState('right', false)
|
230 |
}
|
231 |
};
|
232 |
|
233 |
+
element.addEventListener('blur', function() {
|
234 |
select.setHidden(true);
|
235 |
}, false);
|
236 |
|
237 |
+
element.addEventListener('keydown', function(event) {
|
238 |
switch (event.keyCode) {
|
239 |
case util.keycode.ESCAPE:
|
240 |
select.setHidden(true);
|
242 |
}
|
243 |
}, false);
|
244 |
|
245 |
+
translator.on('error', function() {
|
246 |
this.abort();
|
247 |
self.setState('busy', false)
|
248 |
.setState('error', true);
|
249 |
});
|
250 |
|
251 |
+
translator.on('progress', function(progress) {
|
252 |
switch (progress) {
|
253 |
case 0:
|
254 |
self.setState('busy', true)
|
263 |
});
|
264 |
|
265 |
// custom code
|
266 |
+
function updatePopupSettings() {
|
267 |
+
var container = $("#atlt_strings_model");
|
268 |
container.find(".string_container").scrollTop(0);
|
269 |
+
var scrollHeight = container.find('.string_container').get(0).scrollHeight;
|
270 |
+
var scrollSpeed = 800;
|
271 |
+
if (scrollHeight > scrollSpeed) {
|
272 |
scrollSpeed = scrollHeight;
|
273 |
}
|
274 |
+
if (scrollHeight !== undefined && scrollHeight > 100) {
|
275 |
+
container.find(".my_translate_progress").fadeIn("slow");
|
|
|
276 |
setTimeout(() => {
|
277 |
+
container.find(".string_container").animate({
|
278 |
+
scrollTop: scrollHeight + 2000
|
279 |
+
}, scrollSpeed * 2, 'linear');
|
280 |
}, 1000);
|
281 |
+
|
282 |
container.find('.string_container').on('scroll', function() {
|
283 |
+
if ($(this).scrollTop() + $(this).innerHeight() + 50 >= $(this)[0].scrollHeight) {
|
284 |
setTimeout(() => {
|
285 |
+
container.find(".save_it").prop("disabled", false);
|
286 |
container.find(".ytstats").fadeIn("slow");
|
287 |
container.find(".my_translate_progress").fadeOut("slow");
|
288 |
container.find(".string_container").stop();
|
290 |
}, 1500);
|
291 |
}
|
292 |
});
|
293 |
+
|
294 |
+
if (container.find('.string_container').innerHeight() + 10 >= scrollHeight) {
|
295 |
setTimeout(() => {
|
296 |
+
container.find(".save_it").prop("disabled", false);
|
297 |
container.find(".ytstats").fadeIn("slow");
|
298 |
container.find(".my_translate_progress").fadeOut("slow");
|
299 |
container.find(".string_container").stop();
|
300 |
$('body').css('top', '0');
|
301 |
}, 1500);
|
302 |
}
|
303 |
+
} else {
|
|
|
304 |
setTimeout(() => {
|
305 |
+
// container.find(".save_it").prop("disabled",false);
|
306 |
+
// container.find(".ytstats").fadeIn("slow");
|
307 |
}, 2000);
|
308 |
}
|
309 |
}
|
310 |
|
311 |
+
leftButton.onClick = function() {
|
312 |
select.setHidden(true);
|
313 |
self.translate(select.getValue());
|
314 |
updatePopupSettings();
|
315 |
};
|
316 |
|
317 |
+
rightButton.onClick = function() {
|
318 |
if (self.hasState('active')) {
|
319 |
translator.undo();
|
320 |
self.setState('busy', false)
|
326 |
}
|
327 |
};
|
328 |
|
329 |
+
closeButton.onClick = function() {
|
330 |
select.setHidden(true);
|
331 |
};
|
332 |
+
// defaultLang = storage.getValue('lang') || userLang;
|
333 |
+
if (window.locoConf.conf != undefined) {
|
334 |
+
var defaultcode = window.locoConf.conf.locale.lang ? window.locoConf.conf.locale.lang : null;
|
335 |
+
}
|
336 |
+
switch (defaultcode) {
|
337 |
+
case 'nb':
|
338 |
+
defaultLang = 'no';
|
339 |
+
break;
|
340 |
+
|
341 |
+
case 'nn':
|
342 |
+
defaultLang = 'no';
|
343 |
+
break;
|
344 |
+
default:
|
345 |
+
defaultLang = defaultcode;
|
346 |
+
break;
|
347 |
}
|
348 |
+
// defaultLang = defaultcode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
if (defaultLang) {
|
350 |
select.setValue(defaultLang);
|
351 |
active = storage.getValue('active');
|
354 |
}
|
355 |
}
|
356 |
};
|
357 |
+
Widget.prototype.hasState = function(name) {
|
358 |
return util.hasStyleName(this._element, 'yt-state_' + name);
|
359 |
};
|
360 |
|
361 |
+
Widget.prototype.setState = function(name, enable) {
|
362 |
var hasState = this.hasState(name);
|
363 |
enable = !!enable;
|
364 |
if (enable === hasState) {
|
371 |
return this;
|
372 |
};
|
373 |
|
374 |
+
Widget.prototype.translate = function(targetLang) {
|
375 |
if (targetLang && !this.hasState('active')) {
|
376 |
this._translator.translate(this._pageLang, targetLang);
|
377 |
}
|
378 |
return this;
|
379 |
};
|
380 |
|
381 |
+
Widget.prototype.onStateChange = function() {};
|
382 |
|
383 |
// Storage
|
384 |
|
391 |
}
|
392 |
};
|
393 |
|
394 |
+
Storage.prototype.getValue = function(prop) {
|
395 |
return this._data[prop];
|
396 |
};
|
397 |
|
398 |
+
Storage.prototype.setValue = function(prop, value) {
|
399 |
this._data[prop] = value;
|
400 |
try {
|
401 |
win.localStorage[this._name] = win.JSON.stringify(this._data);
|
407 |
if (!wrapper || !util.isSupportedBrowser()) {
|
408 |
return;
|
409 |
}
|
410 |
+
var initWidget = function() {
|
411 |
+
util.loadScript('https://yastatic.net/s3/translate/v21.4.7/js/tr_page.js', wrapper, function() {
|
|
|
412 |
util.loadResource('https://translate.yandex.net/website-widget/v1/widget.html',
|
413 |
+
function(responseText) {
|
414 |
var element;
|
|
|
415 |
if (!responseText) {
|
416 |
return;
|
417 |
}
|
|
|
418 |
wrapper.innerHTML = responseText;
|
419 |
element = wrapper.querySelector('.yt-widget');
|
420 |
if (params.widgetTheme) {
|
421 |
element.setAttribute('data-theme', params.widgetTheme);
|
422 |
}
|
|
|
423 |
new Widget({
|
424 |
select: new Select(element.querySelector('.yt-listbox'), 'yt-lang'),
|
425 |
element: element,
|
429 |
userLang: (nav.language || nav.userLanguage || '').split('-')[0],
|
430 |
translator: new namespace.PageTranslator({
|
431 |
srv: 'tr-url-widget',
|
432 |
+
//sid: '432eecb0.607a6bda.cceb72be.74722d75726c2d776964676574',
|
|
|
433 |
url: 'https://translate.yandex.net/api/v1/tr.json/translate',
|
434 |
autoSync: true,
|
435 |
maxPortionLength: 600
|
445 |
);
|
446 |
});
|
447 |
};
|
|
|
448 |
if (doc.readyState === 'complete' || doc.readyState === 'interactive') {
|
449 |
initWidget();
|
450 |
} else {
|
451 |
doc.addEventListener('DOMContentLoaded', initWidget, false);
|
452 |
}
|
453 |
+
})(jQuery, this, this.document, this.navigator, { "pageLang": "en", "autoMode": "false", "widgetId": "ytWidget", "widgetTheme": "light" }, this.yt = this.yt || {});
|
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.
|
6 |
License:GPL2
|
7 |
Text Domain:automatic-translator-addon-for-loco-translate
|
8 |
Domain Path:languages
|
@@ -14,7 +14,7 @@ use LocoAutoTranslateAddon\Helpers\Helpers;
|
|
14 |
use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
|
15 |
/**
|
16 |
* @package Loco Automatic Translate Addon
|
17 |
-
* @version 2.
|
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.
|
27 |
|
28 |
class LocoAutoTranslate
|
29 |
{
|
@@ -251,7 +251,7 @@ class LocoAutoTranslate
|
|
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-admin'),ATLT_PRO_VERSION, true);
|
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.2.3
|
6 |
License:GPL2
|
7 |
Text Domain:automatic-translator-addon-for-loco-translate
|
8 |
Domain Path:languages
|
14 |
use LocoAutoTranslateAddon\Helpers\Atlt_downloader;
|
15 |
/**
|
16 |
* @package Loco Automatic Translate Addon
|
17 |
+
* @version 2.2.3
|
18 |
*/
|
19 |
if (!defined('ABSPATH')) {
|
20 |
die('WordPress Environment Not Found!');
|
23 |
define('ATLT_FILE', __FILE__);
|
24 |
define('ATLT_URL', plugin_dir_url(ATLT_FILE));
|
25 |
define('ATLT_PATH', plugin_dir_path(ATLT_FILE));
|
26 |
+
define('ATLT_VERSION', '2.2.3');
|
27 |
|
28 |
class LocoAutoTranslate
|
29 |
{
|
251 |
// if PRO version is installed then load assets
|
252 |
if(Helpers::proInstalled())
|
253 |
{
|
254 |
+
$key=trim(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-admin'),ATLT_PRO_VERSION, true);
|
readme.txt
CHANGED
@@ -3,8 +3,9 @@ Contributors: narinder-singh, satindersingh
|
|
3 |
Donate link: https://paypal.me/CoolPlugins/10USD/
|
4 |
Tags: translate, translation, translator, localization, language, translations, loco, loco translate, loco addon, google translate, deepl
|
5 |
Requires at least: 4.5
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6
|
|
|
8 |
Stable tag: trunk
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -19,6 +20,8 @@ Automatic language translator add-on for Loco Translate official plugin to trans
|
|
19 |
|
20 |
Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin (**1,000,000+ Active Installations**) and automatically machine translates any WordPress plugin or theme translation files into any language.
|
21 |
|
|
|
|
|
22 |
### 🤖 No Translate API Required! + Unlimited Translations!
|
23 |
|
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.
|
@@ -56,7 +59,7 @@ Install this plugin along with the famous **[Loco Translate](https://wordpress.o
|
|
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 |
-
* **
|
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 |
|
@@ -134,6 +137,21 @@ There is no limit. Yes, you can translate unlimited characters without any API k
|
|
134 |
5. Premium License Pricing
|
135 |
|
136 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
<strong>Version 2.1.3 | 11 DEC 2020 </strong>
|
138 |
<pre>
|
139 |
Fixed: Compatibility issues with WordPress 5.6
|
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.9
|
7 |
Requires PHP: 5.6
|
8 |
+
Loco Translate:2.5.8
|
9 |
Stable tag: trunk
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
20 |
|
21 |
Install this plugin along with the famous **[Loco Translate](https://wordpress.org/plugins/loco-translate/)** plugin (**1,000,000+ Active Installations**) and automatically machine translates any WordPress plugin or theme translation files into any language.
|
22 |
|
23 |
+
https://www.youtube.com/watch?v=yBYugUHzwbQ
|
24 |
+
|
25 |
### 🤖 No Translate API Required! + Unlimited Translations!
|
26 |
|
27 |
* 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.
|
59 |
(Limited free docs translations / day or purchase DeepL Pro)
|
60 |
* ✅ **Premium Support:** Quick Email Support
|
61 |
(contact@coolplugins.net -**Support time:- 24-48 hours**)
|
62 |
+
* **Premium License:** [Buy Now 🛒](https://locoaddon.com/addon/loco-automatic-translate-premium-license-key/#pricing)
|
63 |
|
64 |
> DeepL Doc Translator provides limited number of free docs translations per day, you can purchase their pro license to increase this limit.
|
65 |
|
137 |
5. Premium License Pricing
|
138 |
|
139 |
== Changelog ==
|
140 |
+
<strong>Version 2.2.3 | 05/10/2021 </strong>
|
141 |
+
<pre>
|
142 |
+
Fixed:License notice issue
|
143 |
+
</pre>
|
144 |
+
<strong>Version 2.2.2 | 27/04/2021 </strong>
|
145 |
+
<pre>
|
146 |
+
Fixed:Minor ID bug fixes
|
147 |
+
</pre>
|
148 |
+
<strong>Version 2.2 | 17/04/2021 </strong>
|
149 |
+
<pre>
|
150 |
+
Added:Updated Yandex new translation API
|
151 |
+
Fixed:unable to translate issue with Yandex
|
152 |
+
Improved:tested upto WordPress 5.7
|
153 |
+
</pre>
|
154 |
+
|
155 |
<strong>Version 2.1.3 | 11 DEC 2020 </strong>
|
156 |
<pre>
|
157 |
Fixed: Compatibility issues with WordPress 5.6
|