-
Notifications
You must be signed in to change notification settings - Fork 34
/
dict.js
42 lines (37 loc) · 1.05 KB
/
dict.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
dict.init = function() {
window.TT = function(text, args) {
text = T(text)
text.match(/{[^}]+}/g).forEach(function(v) {
text = text.replace(v, T(args[v.slice(1, -1)]));
})
return text;
};
window.TS = function(text) {
return T(util.symbolToString(text));
};
if (!game.config.language.Russian) {
dict.update = function(){}
window.T = function(text) {
return text;
};
return;
}
window.T = function(text) {
return dict[text] || text;
};
dict.update = function(elem) {
var list = {};
function update(elem) {
if (elem.nodeType == 3) {
var text = elem.textContent
elem.textContent = T(text);
list[text] = elem.textContent;
} else if (elem.childNodes.length) {
[].forEach.call(elem.childNodes, update);
}
}
update(elem || document.body);
// console.log(JSON.stringify(list));
}
dict.update();
}