-
Notifications
You must be signed in to change notification settings - Fork 6
/
injection.js
50 lines (44 loc) · 1.25 KB
/
injection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2010 Google Inc. All Rights Reserved.
function injection() {
var pageLang = '{{$pageLang}}';
var userLang = '{{$userLang}}';
var uid = '1E07F158C6FA4460B352973E9693B329';
var teId = 'TE_' + uid;
var cbId = 'TECB_' + uid;
function show() {
window.setTimeout(function() {
window[teId].showBanner(true);
}, 10);
}
function newElem() {
var elem = new google.translate.TranslateElement({
autoDisplay: false,
floatPosition: 0,
multilanguagePage: true,
pageLanguage: pageLang
});
return elem;
}
if (window[teId]) {
show();
} else {
if (!window.google || !google.translate ||
!google.translate.TranslateElement) {
if (!window[cbId]) {
window[cbId] = function() {
window[teId] = newElem();
show();
};
}
var s = document.createElement('script');
s.src = 'https://translate.google.com/translate_a/element.js?cb=' +
encodeURIComponent(cbId) + '&client=tee&hl=' + userLang;
document.getElementsByTagName('head')[0].appendChild(s);
}
}
}
function injector() {
var s = document.createElement('script');
s.innerHTML = '{{$content}}';
document.getElementsByTagName('head')[0].appendChild(s);
}