Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gettext-parser

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gettext-parser - npm Package Compare versions

Comparing version 4.0.0-alpha.0 to 4.0.0-alpha.1

6

CHANGELOG.md
# Change Log
## [4.0.0-alpha.1] - 2019-03-17
- Fix header title casing same when parsing (compiling fixed in 4.0.0-alpha.0)
## [4.0.0-alpha.0] - 2019-03-15
- Update code to ES6
- Fix header tiltle casing when compiling (now enforced for fixed list and left unchanged for all others).

@@ -70,2 +73,3 @@ ## [3.1.1] - 2019-03-14

[4.0.0-alpha.1]: https://github.com/smhg/gettext-parser/compare/v4.0.0-alpha.0...v4.0.0-alpha.1
[4.0.0-alpha.0]: https://github.com/smhg/gettext-parser/compare/v3.1.1...v4.0.0-alpha.0

@@ -72,0 +76,0 @@ [3.1.1]: https://github.com/smhg/gettext-parser/compare/v3.1.0...v3.1.1

14

lib/poparser.js

@@ -51,3 +51,3 @@ const encoding = require('encoding');

} else {
this._handleCharset(fileContents);
this._fileContents = this._handleCharset(fileContents);
}

@@ -63,2 +63,3 @@ }

this._lexer(this._fileContents);
return this._finalize(this._lex);

@@ -79,5 +80,4 @@ };

if ((pos = str.search(/^\s*msgid/im)) >= 0) {
if ((pos = pos + str.substr(pos + 5).search(/^\s*(msgid|msgctxt)/im))) {
headers = str.substr(0, pos);
}
pos = pos + str.substr(pos + 5).search(/^\s*(msgid|msgctxt)/im);
headers = str.substr(0, pos >= 0 ? pos + 5 : str.length);
}

@@ -90,6 +90,6 @@

if (this._charset === 'utf-8') {
this._fileContents = str;
} else {
this._fileContents = this._toString(buf);
return str;
}
return this._toString(buf);
};

@@ -96,0 +96,0 @@

@@ -7,2 +7,3 @@ module.exports.parseHeader = parseHeader;

// see https://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html
const HEADERS = new Map([

@@ -30,18 +31,17 @@ ['project-id-version', 'Project-Id-Version'],

function parseHeader (str = '') {
const lines = str.split('\n');
const headers = {};
return str.split('\n')
.reduce((headers, line) => {
const parts = line.split(':');
let key = (parts.shift() || '').trim();
lines.forEach(line => {
const parts = line.trim().split(':');
const key = (parts.shift() || '').trim().toLowerCase();
const value = parts.join(':').trim();
if (key) {
const value = parts.join(':').trim();
if (!key) {
return;
}
key = HEADERS.get(key.toLowerCase()) || key;
headers[key] = value;
});
headers[key] = value;
}
return headers;
return headers;
}, {});
}

@@ -48,0 +48,0 @@

{
"name": "gettext-parser",
"description": "Parse and compile gettext po and mo files to/from json, nothing more, nothing less",
"version": "4.0.0-alpha.0",
"version": "4.0.0-alpha.1",
"author": "Andris Reinman",

@@ -6,0 +6,0 @@ "contributors": [

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc