if (process.argv.length != 4) { console.log( `Usage: ${process.argv[0]} ${process.argv[1]} ` ); 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);