forked from fultimator/fultimator
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDownloadTranslations.js
39 lines (33 loc) · 972 Bytes
/
DownloadTranslations.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
const https = require("https");
const fs = require("node:fs");
const Papa = require("papaparse");
https
.get(
"https://docs.google.com/spreadsheets/d/1H3GQGaND7PuyiWvFlfIUtmKYquJYEbgs5k8gGbqwUbs/gviz/tq?tqx=out:csv&sheet=Sheet1",
(res) => {
let data = [];
res.on("data", (chunk) => {
data.push(chunk);
});
res.on("end", () => {
const csv = Buffer.concat(data).toString();
const translationJSON = Papa.parse(csv, { header: true });
console.log(translationJSON);
console.log("=== Downloaded Translations ===");
fs.writeFile(
"./src/translation/data.json",
JSON.stringify(translationJSON.data),
(err) => {
if (err) {
console.error(err);
} else {
// file written successfully
}
}
);
});
}
)
.on("error", (err) => {
console.log("Error: ", err.message);
});