From 673cb349fd9ec31dd928590e3ac4efe452a30b60 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 17 Dec 2024 17:13:30 +0100 Subject: [PATCH] Replace po2json with pofile The former doesn't seem to be properly maintained and nodejs gives deprecation warnings. --- package.json | 2 +- po/po2js | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e45fde83d..907cf6309 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "karma-safari-launcher": "latest", "karma-script-launcher": "latest", "mocha": "latest", - "po2json": "latest", + "pofile": "latest", "sinon": "latest", "sinon-chai": "latest" }, diff --git a/po/po2js b/po/po2js index 8d353a1d4..e74b1d4f4 100755 --- a/po/po2js +++ b/po/po2js @@ -19,22 +19,21 @@ const { program } = require('commander'); const fs = require('fs'); -const po2json = require("po2json"); +const pofile = require("pofile"); program .argument('') .argument('') .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}";