Handle extracted comments in headers

This commit is contained in:
Ruben Vermeersch
2015-08-20 15:12:56 +02:00
parent 9060221403
commit b9394176b1
6 changed files with 30 additions and 11 deletions

21
dist/pofile.js vendored
View File

@@ -1,4 +1,6 @@
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"W8CkM0":[function(require,module,exports){
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"pofile":[function(require,module,exports){
module.exports=require('W8CkM0');
},{}],"W8CkM0":[function(require,module,exports){
var fs = require('fs');
var isArray = require('lodash.isarray');
@@ -8,6 +10,7 @@ function trim(string) {
var PO = function () {
this.comments = [];
this.extractedComments = [];
this.headers = {};
this.items = [];
};
@@ -24,6 +27,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 ""');
@@ -87,10 +95,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();
@@ -322,9 +331,7 @@ PO.Item.prototype.toString = function () {
module.exports = PO;
},{"fs":3,"lodash.isarray":4}],"pofile":[function(require,module,exports){
module.exports=require('W8CkM0');
},{}],3:[function(require,module,exports){
},{"fs":3,"lodash.isarray":4}],3:[function(require,module,exports){
},{}],4:[function(require,module,exports){
/**

2
dist/pofile.min.js vendored

File diff suppressed because one or more lines are too long