Skip to content

Commit

Permalink
Replace po2json with pofile
Browse files Browse the repository at this point in the history
The former doesn't seem to be properly maintained and nodejs gives
deprecation warnings.
  • Loading branch information
CendioOssman committed Dec 17, 2024
1 parent 3e2e04b commit 673cb34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"karma-safari-launcher": "latest",
"karma-script-launcher": "latest",
"mocha": "latest",
"po2json": "latest",
"pofile": "latest",
"sinon": "latest",
"sinon-chai": "latest"
},
Expand Down
17 changes: 8 additions & 9 deletions po/po2js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,21 @@

const { program } = require('commander');
const fs = require('fs');
const po2json = require("po2json");
const pofile = require("pofile");

program
.argument('<input>')
.argument('<output>')
.parse(process.argv);

const data = po2json.parseFileSync(program.args[0]);
let data = fs.readFileSync(program.args[0], "utf8");
let po = pofile.parse(data);

const bodyPart = Object.keys(data)
.filter(msgid => msgid !== "")
.filter(msgid => data[msgid][1] !== "")
.map((msgid) => {
const msgstr = data[msgid][1];
return " " + JSON.stringify(msgid) + ": " + JSON.stringify(msgstr);
}).join(",\n");
const bodyPart = po.items
.filter(item => item.msgid !== "")
.filter(item => item.msgstr[0] !== "")
.map(item => " " + JSON.stringify(item.msgid) + ": " + JSON.stringify(item.msgstr[0]))
.join(",\n");

const output = "{\n" + bodyPart + "\n}";

Expand Down

0 comments on commit 673cb34

Please sign in to comment.