-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (34 loc) · 862 Bytes
/
index.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
"use strict";
var uitmuntend = require('uitmuntend'),
unorm = require('unorm'),
fs = require('fs'),
handlebars = require('handlebars');
var main = function() {
var word = process.argv[2];
if (typeof word == "string") {
word = unorm.nfc(process.argv[2]);
uitmuntend.query(word, output);
} else {
throw "error: no valid query string supplied";
}
}
var output = function(data) {
if (typeof data.translations[0] === 'undefined') {
data = {translations: {
original: 'geen resultaten',
translation: 'keine Suchergebnisse'
}}
}
fs.readFile('feedback.tpl.xml', 'utf8', function(err, source) {
if (err) {
throw err;
} else {
var template = handlebars.compile(source);
var result = template(data);
console.log(result);
}
});
}
if (require.main === module) {
main();
}