Handle extracted comments in headers
This commit is contained in:
13
lib/po.js
13
lib/po.js
@@ -7,6 +7,7 @@ function trim(string) {
|
||||
|
||||
var PO = function () {
|
||||
this.comments = [];
|
||||
this.extractedComments = [];
|
||||
this.headers = {};
|
||||
this.items = [];
|
||||
};
|
||||
@@ -23,6 +24,11 @@ PO.prototype.toString = function () {
|
||||
lines.push('# ' + comment);
|
||||
});
|
||||
}
|
||||
if (this.extractedComments) {
|
||||
this.extractedComments.forEach(function (comment) {
|
||||
lines.push('#. ' + comment);
|
||||
});
|
||||
}
|
||||
|
||||
lines.push('msgid ""');
|
||||
lines.push('msgstr ""');
|
||||
@@ -86,10 +92,11 @@ PO.parse = function (data) {
|
||||
acc.push(line);
|
||||
return acc;
|
||||
}, []).forEach(function (header) {
|
||||
if (header.match(/^#/)) {
|
||||
if (header.match(/^#\./)) {
|
||||
po.extractedComments.push(header.replace(/^#\.\s*/, ''));
|
||||
} else if (header.match(/^#/)) {
|
||||
po.comments.push(header.replace(/^#\s*/, ''));
|
||||
}
|
||||
if (header.match(/^"/)) {
|
||||
} else if (header.match(/^"/)) {
|
||||
header = header.trim().replace(/^"/, '').replace(/\\n"$/, '');
|
||||
var p = header.split(/:/);
|
||||
var name = p.shift().trim();
|
||||
|
||||
Reference in New Issue
Block a user