-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
57 lines (52 loc) · 909 Bytes
/
app.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
const axios = require("axios");
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const client = "gtx";
const sl = "auto";
const tl = "si";
const hl = "en-US";
const dt1 = "t";
const dt2 = "bd";
const dj = "1";
const source = "input";
rl.question("Enter the text to translate: ", (answer) => {
translate(answer);
rl.close();
});
function translate(q) {
let config = {
method: "get",
maxBodyLength: Infinity,
url:
"https://translate.googleapis.com/translate_a/single?client=" +
client +
"&sl=" +
sl +
"&tl=" +
tl +
"&hl=" +
hl +
"&dt=" +
dt1 +
"&dt=" +
dt2 +
"&dj=" +
dj +
"&source=" +
source +
"&q=" +
q,
headers: {},
};
axios
.request(config)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error);
});
}