-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.js
59 lines (48 loc) · 1.68 KB
/
sync.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
51
52
53
54
55
56
57
58
59
var converter = require('i18next-conv');
module.exports = {
saveResourceSet: function(lng, ns, resourceSet, callback) {
console.log('not implemented');
callback('not implemented');
},
fetchOne: function(lng, ns, callback) {
var source = this.functions.applyReplacement(this.options.resGetPath, {lng: lng, ns: ns});
var self = this;
converter.addTextDomain(lng, source, {}, function(err, data) {
// console.log(data);
if (err) {
callback(err);
return;
}
converter.parseJSON(lng, data, {}, function(err, json) {
if (err) {
callback(err);
} else {
self.functions.log('loaded file: ' + source);
callback(null, json);
}
});
});
},
saveMissing: function(lng, ns, key, defaultValue, callback) {
console.log('not implemented');
callback('not implemented');
},
postChange: function(lng, ns, key, newValue, callback) {
console.log('not implemented');
callback('not implemented');
},
postRemove: function(lng, ns, key, callback) {
console.log('not implemented');
callback('not implemented');
}
};
// helper
var mergeOptions = function(options, defaultOptions) {
if (!options || typeof options === 'function') {
return defaultOptions;
}
var merged = {};
for (var attrname in defaultOptions) { merged[attrname] = defaultOptions[attrname]; }
for (attrname in options) { if (options[attrname]) merged[attrname] = options[attrname]; }
return merged;
};