8 Commits

Author SHA1 Message Date
Ruben Vermeersch
ff0e5655f9 Release v1.0.7 2017-03-20 10:27:27 +01:00
Ruben Vermeersch
bb56f6e34c Rebuild for #28 2017-03-20 10:27:12 +01:00
Ruben Vermeersch
f035affef6 Merge pull request #28 from dedesite/patch-1
Avoid putting a space in empty comments
2017-03-20 10:26:46 +01:00
Andréas Livet
18a4cc0cb5 Add test to ensure no spaces are added on empty comments 2017-03-20 10:20:04 +01:00
Andréas Livet
0fcff887fe Avoid putting a space in empty comments
In our pipeline, empty comments in po files are generated without
a space after '#' and saving a po file using pofile lib generates
unwanted diff that need to be handle manually which is really annoying.
This pull request simply trim the comment line.
2017-03-17 14:25:20 +01:00
Ruben Vermeersch
9689ae5b7f Release v1.0.6 2017-03-13 19:39:23 +01:00
Ruben Vermeersch
5cbb657f20 Merge pull request #27 from ma2ciek/master
Add support for the typescript projects and IDE-s.
2017-03-13 19:39:04 +01:00
Maciej Bukowski
e038f25d5b Added support for the typescript projects and IDE-s. 2017-03-13 17:40:01 +01:00
7 changed files with 62 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "pofile",
"version": "1.0.5",
"version": "1.0.7",
"authors": [
"Ruben Vermeersch <ruben@rocketeer.be>"
],

4
dist/pofile.js vendored
View File

@@ -23,12 +23,12 @@ PO.prototype.toString = function () {
if (this.comments) {
this.comments.forEach(function (comment) {
lines.push('# ' + comment);
lines.push(('# ' + comment).trim());
});
}
if (this.extractedComments) {
this.extractedComments.forEach(function (comment) {
lines.push('#. ' + comment);
lines.push(('#. ' + comment).trim());
});
}

2
dist/pofile.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -20,12 +20,12 @@ PO.prototype.toString = function () {
if (this.comments) {
this.comments.forEach(function (comment) {
lines.push('# ' + comment);
lines.push(('# ' + comment).trim());
});
}
if (this.extractedComments) {
this.extractedComments.forEach(function (comment) {
lines.push('#. ' + comment);
lines.push(('#. ' + comment).trim());
});
}

View File

@@ -1,7 +1,7 @@
{
"name": "pofile",
"description": "Parse and serialize Gettext PO files.",
"version": "1.0.5",
"version": "1.0.7",
"author": {
"name": "Ruben Vermeersch",
"email": "ruben@savanne.be",
@@ -20,6 +20,7 @@
"url": "http://github.com/rubenv/pofile.git"
},
"main": "./lib/po",
"types": "./pofile.d.ts",
"keywords": [
"i18n",
"l10n",

44
pofile.d.ts vendored Normal file
View File

@@ -0,0 +1,44 @@
declare module "pofile" {
class PO {
public static parse(data: string): PO;
public static load(fileName: string, callback: (err: NodeJS.ErrnoException | null, po: PO) => void): void;
public comments: string[];
public extractedComments: string[];
public items: Item[];
public headers: Partial<IHeaders>
public save(filename: string, callback: (err?: NodeJS.ErrnoException) => void): void;
public toString(): string;
}
interface IHeaders {
'Project-Id-Version': string;
'Report-Msgid-Bugs-To': string;
'POT-Creation-Date': string;
'PO-Revision-Date': string;
'Last-Translator': string;
'Language': string;
'Language-Team': string;
'Content-Type': string;
'Content-Transfer-Encoding': string;
'Plural-Forms': string;
}
class Item {
public msgid: string;
public msgctxt?: string;
public references: string[];
public msgid_plural?: string;
public msgstr: string[];
public comments: string[];
public extractedComments: string[];
public flags: { [flag: string]: boolean | undefined }
private nplurals: number;
private obsolete: boolean;
public toString(): string;
}
export = PO;
}

View File

@@ -2,12 +2,13 @@ var assert = require('assert');
var fs = require('fs');
var PO = require('..');
function assertHasLine(str, line) {
function assertHasLine(str, line, doNotTrim) {
var lines = str.split('\n');
var found = false;
for (var i = 0; i < lines.length; i++) {
if (lines[i].trim() === line) {
var lineToCompare = doNotTrim ? lines[i] : lines[i].trim();
if (lineToCompare === line) {
found = true;
break;
}
@@ -53,6 +54,13 @@ describe('Write', function () {
assertHasLine(str, '#, fuzzy');
});
it('write empty comment without an unecessary space', function () {
var input = fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8');
var po = PO.parse(input);
var str = po.toString();
assertHasLine(str, '#', true);
});
it('write flags only when true', function () {
var input = fs.readFileSync(__dirname + '/fixtures/fuzzy.po', 'utf8');
var po = PO.parse(input);