Socket
Socket
Sign inDemoInstall

po2json

Package Overview
Dependencies
7
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha to 1.0.0-beta

.idea/encodings.xml

0

bower.json

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ 0.4.1 / 2016-04-13

@@ -0,0 +0,0 @@ module.exports = {

@@ -0,0 +0,0 @@ ### Expected Behavior

22

lib/parse.js

@@ -21,3 +21,4 @@ /**

charset: 'utf8',
fullMF: false
fullMF: false,
mfOptions: {},
};

@@ -33,4 +34,5 @@

// defer to gettext-to-messageformat for the 'mf' format option
// use all g2m default replacements except for: pattern: /[\\{}#]/g, replacement: '\\$&'
if (options.format === 'mf') {
result = g2m.parsePo(buffer);
result = Object.keys(options.mfOptions).length > 0 ? g2m.parsePo(buffer, options.mfOptions) : g2m.parsePo(buffer);

@@ -46,9 +48,8 @@ if (options.fullMF) {

// include the default translations at the top level to keep compatibility as much as possible
Object.keys(result['translations']).forEach(function(context) {
Object.keys(result['translations']).forEach(function (context) {
if (context === '') {
Object.keys(result['translations']['']).forEach(function(key) {
Object.keys(result['translations']['']).forEach(function (key) {
mfTranslations[key] = result['translations'][''][key];
});
}
else {
} else {
mfTranslations[context] = result['translations'][context];

@@ -61,2 +62,3 @@ }

}
return options.stringify ? JSON.stringify(mfTranslations, null, options.pretty ? ' ' : null) : mfTranslations;

@@ -70,3 +72,3 @@ }

var result = {},
contexts = parsed.translations;
contexts = parsed.translations;

@@ -86,4 +88,4 @@ Object.keys(contexts).forEach(function (context) {

} else {
if (pluralForms == 'nplurals=1; plural=0;') {
msgstr = t.msgid_plural ? [t.msgstr] : t.msgstr
if (pluralForms === 'nplurals=1; plural=0;') {
msgstr = t.msgid_plural ? [t.msgstr] : t.msgstr;
result[translationKey] = [t.msgid_plural ? t.msgid_plural : null].concat(msgstr);

@@ -143,2 +145,2 @@ } else {

return options.stringify ? JSON.stringify(result, null, options.pretty ? ' ' : null) : result;
}
};

@@ -0,0 +0,0 @@ var fs = require("fs");

@@ -0,0 +0,0 @@ var fs = require("fs");

{
"name": "po2json",
"description": "Convert PO files to JSON",
"version": "1.0.0-alpha",
"version": "1.0.0-beta",
"homepage": "https://github.com/mikeedwards/po2json",

@@ -49,8 +49,3 @@ "author": {

},
"licenses": [
{
"type": "GNU Library General Public License",
"url": "http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html"
}
],
"license": "(LGPL-2.0-or-later)",
"bin": {

@@ -80,4 +75,9 @@ "po2json": "bin/po2json"

"gettext-parser": "2.0.0",
"gettext-to-messageformat": "^0.3.0"
"gettext-to-messageformat": "0.3.0"
},
"peerDependencies": {
"commander": "^2.18.0",
"gettext-parser": "2.0.0",
"gettext-to-messageformat": "0.3.0"
}
}

@@ -0,0 +0,0 @@ # po2json

@@ -0,0 +0,0 @@ {

{"domain":"messages","locale_data":{"messages":{"":{"domain":"messages","plural_forms":"nplurals=1; plural=0;","lang":"ja"},"♂ Male":["男性"],"partner application":["パートナーアプリ"],"result":["検索結果"],"For %s person starting at %s":["For %1$s people starting at %2$s"]}}}

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ {

@@ -295,1 +295,41 @@ var po2json = require(".."),

}
module.exports["handle braces in mf with messageformat options"] ={
setUp: function(callback){
this.po = `
msgid "test"
msgstr "Hi %{firstname}"
`;
//this.json = JSON.parse(`{ "test": "Hi %\\\\{firstname\\\\}" }`);
this.json = JSON.parse(`{ "test": "Hi %{firstname}" }`);
callback();
},
parse: function(test){
const mfOptions = {
replacements: [
{
pattern: /%(\d+)(?:\$\w)?/g,
replacement: (_, n) => `{${n - 1}}`
},
{
pattern: /%\((\w+)\)\w/g,
replacement: '{$1}'
},
{
pattern: /%\w/g,
replacement: function () { return `{${this.n++}}` },
state: { n: 0 }
},
{
pattern: /%%/g,
replacement: '%'
}
]
};
var parsed = po2json.parse(this.po, { format: 'mf', mfOptions: mfOptions });
test.deepEqual(parsed, this.json);
test.done();
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc