-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 1.16 KB
/
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
const readline = require("readline");
const huzz = require("./huzz");
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const extras = true;
console.log("===================================");
console.log("= Huzz Translator =");
console.log("= =");
console.log("= Type into terminal to use =");
console.log("===================================");
console.log("");
console.log("Translations:");
for (const [translated, translateWords] of Object.entries(huzz.translations)) console.log(`${translateWords.join(", ")}: ${translated}`);
if (extras) {
console.log("");
console.log("Extra translations:");
for (const [translated, translateWords] of Object.entries(huzz.extraTranslations)) console.log(`${translateWords.join(", ")}: ${translated}`);
}
console.log("");
(function main() {
// get input
rl.question("Translate: ", inputText => {
if (!inputText) return rl.close(); // no input, return and exit
const outputText = huzz.translate(inputText, true);
console.log(`Translated: ${outputText}`);
console.log("");
main();
});
})();