✨ Parse mo file
This commit is contained in:
parent
0391403f30
commit
0579a6b0ba
6 changed files with 17408 additions and 0 deletions
20
data/gettext/main.js
Normal file
20
data/gettext/main.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
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);
|
Loading…
Add table
Add a link
Reference in a new issue