
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Convert PO files to Javascript objects or JSON strings. The result is Jed-compatible.
Install the module with: npm install po2json
var po2json = require('po2json');
po2json translation.po translation.json
po2json has 3 methods, all of which take exactly the same options. The main function is parse
which actually does the parsing to JSON. The 2 others - parseFile
and parseFileSync
are convenience functions to directly read PO data from a file and convert it to JSON.
Parse a PO buffer to JSON
po2json.parse(buf[, options])
buf
- a po file as a Buffer or an unicode string.options
- an optional object with the following possible parameters:
fuzzy
Whether to include fuzzy translation in JSON or not. Should be either true
or false
. Defaults to false
.stringify
If true
, returns a JSON string. Otherwise returns a plain Javascript object. Defaults to false
.pretty
If true
, the resulting JSON string will be pretty-printed. Has no effect when stringify
is false
. Defaults to false
format
Defaults to raw
.
raw
produces a "raw" JSON outputjed
produces an output that is 100% compatible with Jed < 1.1.0jed1.x
produces an output that is 100% compatible with Jed >= 1.1.0mf
produces simple key:value output.domain
- the domain the messages will be wrapped inside. Only has effect if format: 'jed'
.Parse a PO file to JSON
po2json.parseFile(fileName[,options], cb)
fileName
- path to the po fileoptions
- same as for po2json.parse
cb
- a function that receives 2 arguments: err
and jsonData
Parse a PO file to JSON (synchronous)
po2json.parseFileSync(fileName[, options])
fileName
- path to the po fileoptions
- same as for po2json.parse
If fallback-to-msgid
is set, for those entries that would be omitted
(fuzzy entries without the fuzzy flag) and for those that are empty,
the msgid will be used as translation in the json file.
If the entry is plural, msgid_plural will be used for msgstr[1].
This means that this option makes sense only for those languages
that have nplurals=2.
po2json in command-line parametrization support added to allow override default options.
Note: 'format': 'mf'
means the json format used by messageFormatter in github.com/SlexAxton/messageformat.js
This system does any pluralization within the string, so only msgstr[0] is used with these format, in a simple "key": "value" form.
var po2json = require('po2json'),
fs = require('fs');
fs.readFile('messages.po', function (err, buffer) {
var jsonData = po2json.parse(buffer);
// do something interesting ...
});
var po2json = require('po2json');
po2json.parseFile('messages.po', function (err, jsonData) {
// do something interesting ...
});
var po2json = require('po2json');
var jsonData = '';
try {
jsonData = po2json.parseFileSync('messages.po');
// do something interesting ...
} catch (e) {}
var po2json = require('po2json'),
Jed = require('jed');
po2json.parseFile('messages.po', { format: 'jed' }, function (err, jsonData) {
var i18n = new Jed( jsonData );
});
npm test
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
NB! This release is NOT backwards-compatible! It has the following breaking changes:
po2json.parse_po
has been replaced with po2json.parse
po2json.parse
has been replaced with po2json.parseFile
po2json.parseSync
has been replaced with po2json.parseFileSync
Other changes in this release:
Copyright (c) 2012 Joshua I. Miller Licensed under the GNU, Library, General, Public, License licenses.
FAQs
Convert PO files to JSON
The npm package po2json receives a total of 42,609 weekly downloads. As such, po2json popularity was classified as popular.
We found that po2json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.