dead-cells-wiki/data/gettext/main.js

21 lines
597 B
JavaScript
Raw Permalink Normal View History

2022-09-27 15:08:26 +08:00
if (process.argv.length != 4) {
console.log(
`Usage: ${process.argv[0]} ${process.argv[1]} <input_path> <output_path>`
);
process.exit();
}
const gettextParser = require("gettext-parser");
const prettier = require("prettier");
const fs = require("fs");
const input_path = process.argv[2];
const output_path = process.argv[3];
const input = fs.readFileSync(input_path);
const mo = gettextParser.mo.parse(input, "utf-8");
const mo_json = JSON.stringify(mo.translations[""]);
const pretty_json = prettier.format(mo_json, { parser: "json" });
fs.writeFileSync(output_path, pretty_json);