[Pkg-javascript-commits] [node-gettext-parser] 01/03: New upstream version 1.2.2

Mathias Behrle mbehrle at moszumanska.debian.org
Tue Jan 24 15:29:15 UTC 2017


This is an automated email from the git hooks/post-receive script.

mbehrle pushed a commit to branch master
in repository node-gettext-parser.

commit 904f2349173d93c1dba730ff75fe1ec71ea95c75
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Jan 24 16:24:44 2017 +0100

    New upstream version 1.2.2
---
 .eslintrc.json           |  10 +
 .jshintrc                |  18 --
 .npmignore               |   4 +
 .travis.yml              |   4 -
 CHANGELOG.md             |  77 ++++--
 Gruntfile.js             |  30 --
 README.md                |   7 +-
 index.js                 |  20 +-
 lib/mocompiler.js        | 273 +++++++++----------
 lib/moparser.js          | 206 +++++++-------
 lib/pocompiler.js        | 286 +++++++++-----------
 lib/poparser.js          | 692 ++++++++++++++++++++++++-----------------------
 lib/shared.js            | 122 +++++----
 package.json             |  15 +-
 test/.eslintrc.json      |   5 +
 test/folder-test.js      |  62 ++---
 test/mo-compiler-test.js |  34 +--
 test/mo-parser-test.js   |  34 +--
 test/po-compiler-test.js |  46 ++--
 test/po-parser-test.js   |  94 ++++---
 20 files changed, 1004 insertions(+), 1035 deletions(-)

diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..7fcd746
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,10 @@
+{
+    "extends": "standard",
+    "plugins": [
+        "standard",
+        "promise"
+    ],
+    "rules": {
+        "semi": ["error", "always"]
+    }
+}
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 5a681e8..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-    "indent": 4,
-    "node": true,
-    "globalstrict": true,
-    "evil": true,
-    "unused": true,
-    "undef": true,
-    "newcap": true,
-    "esnext": true,
-    "curly": true,
-    "eqeqeq": true,
-    "expr": true,
-
-    "predef": [
-        "describe",
-        "it"
-    ]
-}
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..2fb9f8a
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,4 @@
+test
+.eslintrc.json
+.gitignore
+.travis.yml
diff --git a/.travis.yml b/.travis.yml
index b00f478..f693a56 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,9 +4,5 @@ node_js:
   - "0.12"
   - "4"
   - "6"
-
-before_install:
-  - npm install -g grunt-cli
-
 notifications:
   email: false
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f33ed09..abf2109 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,30 +1,47 @@
-# Changelog
-
-## v1.1.2 2015-10-07
-
-  * Maintenance release
-
-## v1.1.1 2015-06-04
-
-  * Fixed hash table location value in compiled mo files
-
-## v1.1.0 2015-01-21
-
-  * Added `po.createParseStream` method for parsing PO files from a Stream source
-  * Updated documentation
-
-## v1.0.0 2015-01-21
-
-  * Bumped version to 1.0.0 to be compatible with semver
-  * Changed tests from nodeunit to mocha
-  * Unified code style in files and added jshint task to check it
-  * Added Grunt support to check style and run tests on `npm test`
-
-## v0.2.0 2013-12-30
-
-  * Bumped version to 0.2.0
-  * Removed node-iconv dependency
-  * Fixed a global variable leak (`line` was not defined in `pocompiler._addPOString`)
-  * Some code maintenance (applied jshint rules, added "use strict" statements)
-  * Updated e-mail address in .travis.yml
-  * Added CHANGELOG file
+# Change Log
+
+## [1.2.2] - 2017-01-11
+- Use semistandard coding style.
+- Removed unreachable code (thx @jelly).
+- Replace grunt with npm scripts.
+- Replace jshint with eslint.
+
+## [1.2.1] - 2016-11-26
+- Fix typo in readme (thx @TimKam).
+- New project maintainer.
+
+## [1.2.0] - 2016-06-13
+- Fix compilation of plurals when msgstr only contains one element (thx @maufl).
+- Fix example in readme (thx @arthuralee).
+
+## [1.1.2] - 2015-10-07
+- Update dependencies.
+
+## [1.1.1] - 2015-06-04
+- Fixed hash table location value in compiled mo files
+
+## [1.1.0] - 2015-01-21
+- Added `po.createParseStream` method for parsing PO files from a Stream source
+- Updated documentation
+
+## [1.0.0] - 2015-01-21
+- Bumped version to 1.0.0 to be compatible with semver
+- Changed tests from nodeunit to mocha
+- Unified code style in files and added jshint task to check it
+- Added Grunt support to check style and run tests on `npm test`
+
+## [0.2.0] - 2013-12-30
+- Removed node-iconv dependency
+- Fixed a global variable leak (`line` was not defined in `pocompiler._addPOString`)
+- Some code maintenance (applied jshint rules, added "use strict" statements)
+- Updated e-mail address in .travis.yml
+- Added CHANGELOG file
+
+[1.2.2]: https://github.com/smhg/gettext-parser/compare/v1.2.1...v1.2.2
+[1.2.1]: https://github.com/smhg/gettext-parser/compare/v1.2.0...v1.2.1
+[1.2.0]: https://github.com/smhg/gettext-parser/compare/v1.1.2...v1.2.0
+[1.1.2]: https://github.com/smhg/gettext-parser/compare/v1.1.1...v1.1.2
+[1.1.1]: https://github.com/smhg/gettext-parser/compare/v1.1.0...v1.1.1
+[1.1.0]: https://github.com/smhg/gettext-parser/compare/v1.0.0...v1.1.0
+[1.0.0]: https://github.com/smhg/gettext-parser/compare/v0.2.0...v1.0.0
+[0.2.0]: https://github.com/smhg/gettext-parser/compare/v0.1.10...v0.2.0
\ No newline at end of file
diff --git a/Gruntfile.js b/Gruntfile.js
deleted file mode 100644
index 9901d1f..0000000
--- a/Gruntfile.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-
-module.exports = function(grunt) {
-
-    // Project configuration.
-    grunt.initConfig({
-        jshint: {
-            all: ['lib/*.js', 'test/*.js', 'index.js'],
-            options: {
-                jshintrc: '.jshintrc'
-            }
-        },
-
-        mochaTest: {
-            all: {
-                options: {
-                    reporter: 'spec'
-                },
-                src: ['test/*-test.js']
-            }
-        }
-    });
-
-    // Load the plugin(s)
-    grunt.loadNpmTasks('grunt-contrib-jshint');
-    grunt.loadNpmTasks('grunt-mocha-test');
-
-    // Tasks
-    grunt.registerTask('default', ['jshint', 'mochaTest']);
-};
\ No newline at end of file
diff --git a/README.md b/README.md
index caa61c3..e61f7c7 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,8 @@
-gettext-parser
+gettext-parser [![Build Status](https://secure.travis-ci.org/smhg/gettext-parser.png)](http://travis-ci.org/smhg/gettext-parser)
 ==============
 
-[![Build Status](https://secure.travis-ci.org/smhg/gettext-parser.png)](http://travis-ci.org/smhg/gettext-parser)
-[![NPM version](https://badge.fury.io/js/gettext-parser.png)](http://badge.fury.io/js/gettext-parser)
-
 Parse and compile gettext *po* and *mo* files with node.js, nothing more, nothing less.
 
-This module is slightly based on another gettext related module [node-gettext](https://github.com/andris9/node-gettext). The plan is to move all parsing and compiling logic from node-gettext to here and leave only translation related functions (domains, plural handling, lookups etc.).
-
 ## Usage
 
 Include the library:
diff --git a/index.js b/index.js
index d02fbae..4ae18d9 100644
--- a/index.js
+++ b/index.js
@@ -3,14 +3,14 @@
 var poParser = require('./lib/poparser');
 
 module.exports = {
-    po: {
-        parse: poParser.parse,
-        createParseStream: poParser.stream,
-        compile: require('./lib/pocompiler')
-    },
+  po: {
+    parse: poParser.parse,
+    createParseStream: poParser.stream,
+    compile: require('./lib/pocompiler')
+  },
 
-    mo: {
-        parse: require('./lib/moparser'),
-        compile: require('./lib/mocompiler')
-    }
-};
\ No newline at end of file
+  mo: {
+    parse: require('./lib/moparser'),
+    compile: require('./lib/mocompiler')
+  }
+};
diff --git a/lib/mocompiler.js b/lib/mocompiler.js
index 6f489cc..d0a690d 100644
--- a/lib/mocompiler.js
+++ b/lib/mocompiler.js
@@ -10,9 +10,9 @@ var sharedFuncs = require('./shared');
  * @param {Object} table Translation object
  * @return {Buffer} Compiled binary MO object
  */
-module.exports = function(table) {
-    var compiler = new Compiler(table);
-    return compiler.compile();
+module.exports = function (table) {
+  var compiler = new Compiler(table);
+  return compiler.compile();
 };
 
 /**
@@ -21,16 +21,16 @@ module.exports = function(table) {
  * @constructor
  * @param {Object} table Translation table as defined in the README
  */
-function Compiler(table) {
-    this._table = table || {};
-    this._table.headers = this._table.headers || {};
-    this._table.translations = this._table.translations || {};
+function Compiler (table) {
+  this._table = table || {};
+  this._table.headers = this._table.headers || {};
+  this._table.translations = this._table.translations || {};
 
-    this._translations = [];
+  this._translations = [];
 
-    this._writeFunc = 'writeUInt32LE';
+  this._writeFunc = 'writeUInt32LE';
 
-    this._handleCharset();
+  this._handleCharset();
 }
 
 /**
@@ -41,36 +41,36 @@ Compiler.prototype.MAGIC = 0x950412de;
 /**
  * Handles header values, replaces or adds (if needed) a charset property
  */
-Compiler.prototype._handleCharset = function() {
-    var parts = (this._table.headers['content-type'] || 'text/plain').split(';'),
-        contentType = parts.shift(),
-        charset = sharedFuncs.formatCharset(this._table.charset),
-        params = [];
-
-    params = parts.map(function(part) {
-        var parts = part.split('='),
-            key = parts.shift().trim(),
-            value = parts.join('=');
-
-        if (key.toLowerCase() === 'charset') {
-            if (!charset) {
-                charset = sharedFuncs.formatCharset(value.trim() || 'utf-8');
-            }
-            return 'charset=' + charset;
-        }
-
-        return part;
-    });
-
-    if (!charset) {
-        charset = this._table.charset || 'utf-8';
-        params.push('charset=' + charset);
+Compiler.prototype._handleCharset = function () {
+  var parts = (this._table.headers['content-type'] || 'text/plain').split(';');
+  var contentType = parts.shift();
+  var charset = sharedFuncs.formatCharset(this._table.charset);
+  var params = [];
+
+  params = parts.map(function (part) {
+    var parts = part.split('=');
+    var key = parts.shift().trim();
+    var value = parts.join('=');
+
+    if (key.toLowerCase() === 'charset') {
+      if (!charset) {
+        charset = sharedFuncs.formatCharset(value.trim() || 'utf-8');
+      }
+      return 'charset=' + charset;
     }
 
-    this._table.charset = charset;
-    this._table.headers['content-type'] = contentType + '; ' + params.join('; ');
+    return part;
+  });
 
-    this._charset = charset;
+  if (!charset) {
+    charset = this._table.charset || 'utf-8';
+    params.push('charset=' + charset);
+  }
+
+  this._table.charset = charset;
+  this._table.headers['content-type'] = contentType + '; ' + params.join('; ');
+
+  this._charset = charset;
 };
 
 /**
@@ -79,48 +79,48 @@ Compiler.prototype._handleCharset = function() {
  *
  * @return {Array} Translation strings array
  */
-Compiler.prototype._generateList = function() {
-    var list = [];
-
-    list.push({
-        msgid: new Buffer(0),
-        msgstr: encoding.convert(sharedFuncs.generateHeader(this._table.headers), this._charset)
-    });
-
-    Object.keys(this._table.translations).forEach((function(msgctxt) {
-        if (typeof this._table.translations[msgctxt] !== 'object') {
-            return;
-        }
-        Object.keys(this._table.translations[msgctxt]).forEach((function(msgid) {
-            if (typeof this._table.translations[msgctxt][msgid] !== 'object') {
-                return;
-            }
-            if (msgctxt === '' && msgid === '') {
-                return;
-            }
-
-            var msgid_plural = this._table.translations[msgctxt][msgid].msgid_plural,
-                key = msgid,
-                value;
-
-            if (msgctxt) {
-                key = msgctxt + '\u0004' + key;
-            }
-
-            if (msgid_plural) {
-                key += '\u0000' + msgid_plural;
-            }
-
-            value = [].concat(this._table.translations[msgctxt][msgid].msgstr || []).join('\u0000');
-
-            list.push({
-                msgid: encoding.convert(key, this._charset),
-                msgstr: encoding.convert(value, this._charset)
-            });
-        }).bind(this));
-    }).bind(this));
-
-    return list;
+Compiler.prototype._generateList = function () {
+  var list = [];
+
+  list.push({
+    msgid: new Buffer(0),
+    msgstr: encoding.convert(sharedFuncs.generateHeader(this._table.headers), this._charset)
+  });
+
+  Object.keys(this._table.translations).forEach(function (msgctxt) {
+    if (typeof this._table.translations[msgctxt] !== 'object') {
+      return;
+    }
+    Object.keys(this._table.translations[msgctxt]).forEach(function (msgid) {
+      if (typeof this._table.translations[msgctxt][msgid] !== 'object') {
+        return;
+      }
+      if (msgctxt === '' && msgid === '') {
+        return;
+      }
+
+      var msgidPlural = this._table.translations[msgctxt][msgid].msgid_plural;
+      var key = msgid;
+      var value;
+
+      if (msgctxt) {
+        key = msgctxt + '\u0004' + key;
+      }
+
+      if (msgidPlural) {
+        key += '\u0000' + msgidPlural;
+      }
+
+      value = [].concat(this._table.translations[msgctxt][msgid].msgstr || []).join('\u0000');
+
+      list.push({
+        msgid: encoding.convert(key, this._charset),
+        msgstr: encoding.convert(value, this._charset)
+      });
+    }.bind(this));
+  }.bind(this));
+
+  return list;
 };
 
 /**
@@ -129,17 +129,17 @@ Compiler.prototype._generateList = function() {
  * @param {Array} list An array of translation strings from _generateList
  * @return {Object} Size data of {msgid, msgstr, total}
  */
-Compiler.prototype._calculateSize = function(list) {
-    var msgidLength = 0,
-        msgstrLength = 0,
-        totalLength = 0;
+Compiler.prototype._calculateSize = function (list) {
+  var msgidLength = 0;
+  var msgstrLength = 0;
+  var totalLength = 0;
 
-    list.forEach(function(translation) {
-        msgidLength += translation.msgid.length + 1; // + extra 0x00
-        msgstrLength += translation.msgstr.length + 1; // + extra 0x00
-    });
+  list.forEach(function (translation) {
+    msgidLength += translation.msgid.length + 1; // + extra 0x00
+    msgstrLength += translation.msgstr.length + 1; // + extra 0x00
+  });
 
-    totalLength = 4 + // magic number
+  totalLength = 4 + // magic number
         4 + // revision
         4 + // string count
         4 + // original string table offset
@@ -151,11 +151,11 @@ Compiler.prototype._calculateSize = function(list) {
         msgidLength + // originals
         msgstrLength; // translations
 
-    return {
-        msgid: msgidLength,
-        msgstr: msgstrLength,
-        total: totalLength
-    };
+  return {
+    msgid: msgidLength,
+    msgstr: msgstrLength,
+    total: totalLength
+  };
 };
 
 /**
@@ -165,52 +165,53 @@ Compiler.prototype._calculateSize = function(list) {
  * @param {Object} size Byte size information
  * @return {Buffer} Compiled MO object
  */
-Compiler.prototype._build = function(list, size) {
-    var returnBuffer = new Buffer(size.total),
-        curPosition = 0,
-        i, len;
+Compiler.prototype._build = function (list, size) {
+  var returnBuffer = new Buffer(size.total);
+  var curPosition = 0;
+  var i;
+  var len;
 
     // magic
-    returnBuffer[this._writeFunc](this.MAGIC, 0);
+  returnBuffer[this._writeFunc](this.MAGIC, 0);
 
     // revision
-    returnBuffer[this._writeFunc](0, 4);
+  returnBuffer[this._writeFunc](0, 4);
 
     // string count
-    returnBuffer[this._writeFunc](list.length, 8);
+  returnBuffer[this._writeFunc](list.length, 8);
 
     // original string table offset
-    returnBuffer[this._writeFunc](28, 12);
+  returnBuffer[this._writeFunc](28, 12);
 
     // translation string table offset
-    returnBuffer[this._writeFunc](28 + (4 + 4) * list.length, 16);
+  returnBuffer[this._writeFunc](28 + (4 + 4) * list.length, 16);
 
     // hash table size
-    returnBuffer[this._writeFunc](0, 20);
+  returnBuffer[this._writeFunc](0, 20);
 
     // hash table offset
-    returnBuffer[this._writeFunc](28 + (4 + 4) * list.length * 2, 24);
+  returnBuffer[this._writeFunc](28 + (4 + 4) * list.length * 2, 24);
 
     // build originals table
-    curPosition = 28 + 2 * (4 + 4) * list.length;
-    for (i = 0, len = list.length; i < len; i++) {
-        list[i].msgid.copy(returnBuffer, curPosition);
-        returnBuffer[this._writeFunc](list[i].msgid.length, 28 + i * 8);
-        returnBuffer[this._writeFunc](curPosition, 28 + i * 8 + 4);
-        returnBuffer[curPosition + list[i].msgid.length] = 0x00;
-        curPosition += list[i].msgid.length + 1;
-    }
+  curPosition = 28 + 2 * (4 + 4) * list.length;
+  for (i = 0, len = list.length; i < len; i++) {
+    list[i].msgid.copy(returnBuffer, curPosition);
+    returnBuffer[this._writeFunc](list[i].msgid.length, 28 + i * 8);
+    returnBuffer[this._writeFunc](curPosition, 28 + i * 8 + 4);
+    returnBuffer[curPosition + list[i].msgid.length] = 0x00;
+    curPosition += list[i].msgid.length + 1;
+  }
 
     // build translations table
-    for (i = 0, len = list.length; i < len; i++) {
-        list[i].msgstr.copy(returnBuffer, curPosition);
-        returnBuffer[this._writeFunc](list[i].msgstr.length, 28 + (4 + 4) * list.length + i * 8);
-        returnBuffer[this._writeFunc](curPosition, 28 + (4 + 4) * list.length + i * 8 + 4);
-        returnBuffer[curPosition + list[i].msgstr.length] = 0x00;
-        curPosition += list[i].msgstr.length + 1;
-    }
-
-    return returnBuffer;
+  for (i = 0, len = list.length; i < len; i++) {
+    list[i].msgstr.copy(returnBuffer, curPosition);
+    returnBuffer[this._writeFunc](list[i].msgstr.length, 28 + (4 + 4) * list.length + i * 8);
+    returnBuffer[this._writeFunc](curPosition, 28 + (4 + 4) * list.length + i * 8 + 4);
+    returnBuffer[curPosition + list[i].msgstr.length] = 0x00;
+    curPosition += list[i].msgstr.length + 1;
+  }
+
+  return returnBuffer;
 };
 
 /**
@@ -218,20 +219,20 @@ Compiler.prototype._build = function(list, size) {
  *
  * @return {Buffer} Compiled MO object
  */
-Compiler.prototype.compile = function() {
-    var list = this._generateList(),
-        size = this._calculateSize(list);
+Compiler.prototype.compile = function () {
+  var list = this._generateList();
+  var size = this._calculateSize(list);
 
     // sort by msgid
-    list.sort(function(a, b) {
-        if (a.msgid > b.msgid) {
-            return 1;
-        }
-        if (a.msgid < b.msgid) {
-            return -1;
-        }
-        return 0;
-    });
-
-    return this._build(list, size);
-};
\ No newline at end of file
+  list.sort(function (a, b) {
+    if (a.msgid > b.msgid) {
+      return 1;
+    }
+    if (a.msgid < b.msgid) {
+      return -1;
+    }
+    return 0;
+  });
+
+  return this._build(list, size);
+};
diff --git a/lib/moparser.js b/lib/moparser.js
index 8c20471..32849a9 100644
--- a/lib/moparser.js
+++ b/lib/moparser.js
@@ -10,9 +10,9 @@ var sharedFuncs = require('./shared');
  * @param {String} [defaultCharset] Default charset to use
  * @return {Object} Translation object
  */
-module.exports = function(buffer, defaultCharset) {
-    var parser = new Parser(buffer, defaultCharset);
-    return parser.parse();
+module.exports = function (buffer, defaultCharset) {
+  var parser = new Parser(buffer, defaultCharset);
+  return parser.parse();
 };
 
 /**
@@ -22,27 +22,26 @@ module.exports = function(buffer, defaultCharset) {
  * @param {Buffer} fileContents Binary MO object
  * @param {String} [defaultCharset] Default charset to use
  */
-function Parser(fileContents, defaultCharset) {
-
-    this._fileContents = fileContents;
+function Parser (fileContents, defaultCharset) {
+  this._fileContents = fileContents;
 
     /**
      * Method name for writing int32 values, default littleendian
      */
-    this._writeFunc = 'writeUInt32LE';
+  this._writeFunc = 'writeUInt32LE';
 
     /**
      * Method name for reading int32 values, default littleendian
      */
-    this._readFunc = 'readUInt32LE';
+  this._readFunc = 'readUInt32LE';
 
-    this._charset = defaultCharset || 'iso-8859-1';
+  this._charset = defaultCharset || 'iso-8859-1';
 
-    this._table = {
-        charset: this._charset,
-        headers: undefined,
-        translations: {}
-    };
+  this._table = {
+    charset: this._charset,
+    headers: undefined,
+    translations: {}
+  };
 }
 
 /**
@@ -55,57 +54,59 @@ Parser.prototype.MAGIC = 0x950412de;
  *
  * @return {Boolean} Return true if magic was detected
  */
-Parser.prototype._checkMagick = function() {
-    if (this._fileContents.readUInt32LE(0) === this.MAGIC) {
-        this._readFunc = 'readUInt32LE';
-        this._writeFunc = 'writeUInt32LE';
-        return true;
-    } else if (this._fileContents.readUInt32BE(0) === this.MAGIC) {
-        this._readFunc = 'readUInt32BE';
-        this._writeFunc = 'writeUInt32BE';
-        return true;
-    } else {
-        return false;
-    }
+Parser.prototype._checkMagick = function () {
+  if (this._fileContents.readUInt32LE(0) === this.MAGIC) {
+    this._readFunc = 'readUInt32LE';
+    this._writeFunc = 'writeUInt32LE';
+    return true;
+  } else if (this._fileContents.readUInt32BE(0) === this.MAGIC) {
+    this._readFunc = 'readUInt32BE';
+    this._writeFunc = 'writeUInt32BE';
+    return true;
+  } else {
+    return false;
+  }
 };
 
 /**
  * Read the original strings and translations from the input MO file. Use the
  * first translation string in the file as the header.
  */
-Parser.prototype._loadTranslationTable = function() {
-    var offsetOriginals = this._offsetOriginals,
-        offsetTranslations = this._offsetTranslations,
-        position, length,
-        msgid, msgstr;
-
-    for (var i = 0; i < this._total; i++) {
+Parser.prototype._loadTranslationTable = function () {
+  var offsetOriginals = this._offsetOriginals;
+  var offsetTranslations = this._offsetTranslations;
+  var position;
+  var length;
+  var msgid;
+  var msgstr;
+
+  for (var i = 0; i < this._total; i++) {
         // msgid string
-        length = this._fileContents[this._readFunc](offsetOriginals);
-        offsetOriginals += 4;
-        position = this._fileContents[this._readFunc](offsetOriginals);
-        offsetOriginals += 4;
-        msgid = this._fileContents.slice(position, position + length);
+    length = this._fileContents[this._readFunc](offsetOriginals);
+    offsetOriginals += 4;
+    position = this._fileContents[this._readFunc](offsetOriginals);
+    offsetOriginals += 4;
+    msgid = this._fileContents.slice(position, position + length);
 
         // matching msgstr
-        length = this._fileContents[this._readFunc](offsetTranslations);
-        offsetTranslations += 4;
-        position = this._fileContents[this._readFunc](offsetTranslations);
-        offsetTranslations += 4;
-        msgstr = this._fileContents.slice(position, position + length);
-
-        if (!i && !msgid.toString()) {
-            this._handleCharset(msgstr);
-        }
+    length = this._fileContents[this._readFunc](offsetTranslations);
+    offsetTranslations += 4;
+    position = this._fileContents[this._readFunc](offsetTranslations);
+    offsetTranslations += 4;
+    msgstr = this._fileContents.slice(position, position + length);
+
+    if (!i && !msgid.toString()) {
+      this._handleCharset(msgstr);
+    }
 
-        msgid = encoding.convert(msgid, 'utf-8', this._charset).toString('utf-8');
-        msgstr = encoding.convert(msgstr, 'utf-8', this._charset).toString('utf-8');
+    msgid = encoding.convert(msgid, 'utf-8', this._charset).toString('utf-8');
+    msgstr = encoding.convert(msgstr, 'utf-8', this._charset).toString('utf-8');
 
-        this._addString(msgid, msgstr);
-    }
+    this._addString(msgid, msgstr);
+  }
 
     // dump the file contents object
-    this._fileContents = null;
+  this._fileContents = null;
 };
 
 /**
@@ -113,18 +114,17 @@ Parser.prototype._loadTranslationTable = function() {
  *
  * @param {Buffer} headers Header value
  */
-Parser.prototype._handleCharset = function(headers) {
-
-    var headersStr = headers.toString(),
-        match;
+Parser.prototype._handleCharset = function (headers) {
+  var headersStr = headers.toString();
+  var match;
 
-    if ((match = headersStr.match(/[; ]charset\s*=\s*([\w\-]+)/i))) {
-        this._charset = this._table.charset = sharedFuncs.formatCharset(match[1], this._charset);
-    }
+  if ((match = headersStr.match(/[; ]charset\s*=\s*([\w-]+)/i))) {
+    this._charset = this._table.charset = sharedFuncs.formatCharset(match[1], this._charset);
+  }
 
-    headers = encoding.convert(headers, 'utf-8', this._charset).toString('utf-8');
+  headers = encoding.convert(headers, 'utf-8', this._charset).toString('utf-8');
 
-    this._table.headers = sharedFuncs.parseHeader(headers);
+  this._table.headers = sharedFuncs.parseHeader(headers);
 };
 
 /**
@@ -133,36 +133,38 @@ Parser.prototype._handleCharset = function(headers) {
  * @param {String} msgid Original string
  * @params {String} msgstr Translation for the original string
  */
-Parser.prototype._addString = function(msgid, msgstr) {
-    var translation = {},
-        parts, msgctxt, msgid_plural;
-
-    msgid = msgid.split('\u0004');
-    if (msgid.length > 1) {
-        msgctxt = msgid.shift();
-        translation.msgctxt = msgctxt;
-    } else {
-        msgctxt = '';
-    }
-    msgid = msgid.join('\u0004');
-
-    parts = msgid.split('\u0000');
-    msgid = parts.shift();
-
-    translation.msgid = msgid;
-
-    if ((msgid_plural = parts.join('\u0000'))) {
-        translation.msgid_plural = msgid_plural;
-    }
-
-    msgstr = msgstr.split('\u0000');
-    translation.msgstr = [].concat(msgstr || []);
-
-    if (!this._table.translations[msgctxt]) {
-        this._table.translations[msgctxt] = {};
-    }
-
-    this._table.translations[msgctxt][msgid] = translation;
+Parser.prototype._addString = function (msgid, msgstr) {
+  var translation = {};
+  var parts;
+  var msgctxt;
+  var msgidPlural;
+
+  msgid = msgid.split('\u0004');
+  if (msgid.length > 1) {
+    msgctxt = msgid.shift();
+    translation.msgctxt = msgctxt;
+  } else {
+    msgctxt = '';
+  }
+  msgid = msgid.join('\u0004');
+
+  parts = msgid.split('\u0000');
+  msgid = parts.shift();
+
+  translation.msgid = msgid;
+
+  if ((msgidPlural = parts.join('\u0000'))) {
+    translation.msgid_plural = msgidPlural;
+  }
+
+  msgstr = msgstr.split('\u0000');
+  translation.msgstr = [].concat(msgstr || []);
+
+  if (!this._table.translations[msgctxt]) {
+    this._table.translations[msgctxt] = {};
+  }
+
+  this._table.translations[msgctxt][msgid] = translation;
 };
 
 /**
@@ -170,33 +172,33 @@ Parser.prototype._addString = function(msgid, msgstr) {
  *
  * @return {Object} Translation table
  */
-Parser.prototype.parse = function() {
-    if (!this._checkMagick()) {
-        return false;
-    }
+Parser.prototype.parse = function () {
+  if (!this._checkMagick()) {
+    return false;
+  }
 
     /**
      * GetText revision nr, usually 0
      */
-    this._revision = this._fileContents[this._readFunc](4);
+  this._revision = this._fileContents[this._readFunc](4);
 
     /**
      * Total count of translated strings
      */
-    this._total = this._fileContents[this._readFunc](8);
+  this._total = this._fileContents[this._readFunc](8);
 
     /**
      * Offset position for original strings table
      */
-    this._offsetOriginals = this._fileContents[this._readFunc](12);
+  this._offsetOriginals = this._fileContents[this._readFunc](12);
 
     /**
      * Offset position for translation strings table
      */
-    this._offsetTranslations = this._fileContents[this._readFunc](16);
+  this._offsetTranslations = this._fileContents[this._readFunc](16);
 
     // Load translations into this._translationTable
-    this._loadTranslationTable();
+  this._loadTranslationTable();
 
-    return this._table;
-};
\ No newline at end of file
+  return this._table;
+};
diff --git a/lib/pocompiler.js b/lib/pocompiler.js
index 6285295..93efded 100644
--- a/lib/pocompiler.js
+++ b/lib/pocompiler.js
@@ -10,9 +10,9 @@ var sharedFuncs = require('./shared');
  * @param {Object} table Translation object
  * @return {Buffer} Compiled PO object
  */
-module.exports = function(table) {
-    var compiler = new Compiler(table);
-    return compiler.compile();
+module.exports = function (table) {
+  var compiler = new Compiler(table);
+  return compiler.compile();
 };
 
 /**
@@ -21,12 +21,12 @@ module.exports = function(table) {
  * @constructor
  * @param {Object} table Translation table to be compiled
  */
-function Compiler(table) {
-    this._table = table || {};
-    this._table.headers = this._table.headers || {};
-    this._table.translations = this._table.translations || {};
-    this._translations = [];
-    this._handleCharset();
+function Compiler (table) {
+  this._table = table || {};
+  this._table.headers = this._table.headers || {};
+  this._table.translations = this._table.translations || {};
+  this._translations = [];
+  this._handleCharset();
 }
 
 /**
@@ -36,35 +36,35 @@ function Compiler(table) {
  * @param {Object} comments A comments object
  * @return {String} A comment string for the PO file
  */
-Compiler.prototype._drawComments = function(comments) {
-    var lines = [];
-    var types = [{
-        key: 'translator',
-        prefix: '# '
-    }, {
-        key: 'reference',
-        prefix: '#: '
-    }, {
-        key: 'extracted',
-        prefix: '#. '
-    }, {
-        key: 'flag',
-        prefix: '#, '
-    }, {
-        key: 'previous',
-        prefix: '#| '
-    }];
-
-    types.forEach(function(type) {
-        if (!comments[type.key]) {
-            return;
-        }
-        comments[type.key].split(/\r?\n|\r/).forEach(function(line) {
-            lines.push(type.prefix + line);
-        });
+Compiler.prototype._drawComments = function (comments) {
+  var lines = [];
+  var types = [{
+    key: 'translator',
+    prefix: '# '
+  }, {
+    key: 'reference',
+    prefix: '#: '
+  }, {
+    key: 'extracted',
+    prefix: '#. '
+  }, {
+    key: 'flag',
+    prefix: '#, '
+  }, {
+    key: 'previous',
+    prefix: '#| '
+  }];
+
+  types.forEach(function (type) {
+    if (!comments[type.key]) {
+      return;
+    }
+    comments[type.key].split(/\r?\n|\r/).forEach(function (line) {
+      lines.push(type.prefix + line);
     });
+  });
 
-    return lines.join('\n');
+  return lines.join('\n');
 };
 
 /**
@@ -74,39 +74,37 @@ Compiler.prototype._drawComments = function(comments) {
  * @param {Object} [override] Properties of this object will override `block` properties
  * @return {String} Translation string for a single object
  */
-Compiler.prototype._drawBlock = function(block, override) {
-
-    override = override || {};
-
-    var response = [],
-        comments = override.comments || block.comments,
-        msgctxt = override.msgctxt || block.msgctxt,
-        msgid = override.msgid || block.msgid,
-        msgid_plural = override.msgid_plural || block.msgid_plural,
-        msgstr = [].concat(override.msgstr || block.msgstr);
+Compiler.prototype._drawBlock = function (block, override) {
+  override = override || {};
 
+  var response = [];
+  var comments = override.comments || block.comments;
+  var msgctxt = override.msgctxt || block.msgctxt;
+  var msgid = override.msgid || block.msgid;
+  var msgidPlural = override.msgid_plural || block.msgid_plural;
+  var msgstr = [].concat(override.msgstr || block.msgstr);
 
     // add comments
-    if (comments && (comments = this._drawComments(comments))) {
-        response.push(comments);
-    }
-
-    if (msgctxt) {
-        response.push(this._addPOString('msgctxt', msgctxt));
-    }
-
-    response.push(this._addPOString('msgid', msgid || ''));
-
-    if (msgid_plural) {
-        response.push(this._addPOString('msgid_plural', msgid_plural));
-        msgstr.forEach((function(msgstr, i) {
-            response.push(this._addPOString('msgstr[' + i + ']', msgstr || ''));
-        }).bind(this));
-    } else {
-        response.push(this._addPOString('msgstr', msgstr[0] || ''));
-    }
-
-    return response.join('\n');
+  if (comments && (comments = this._drawComments(comments))) {
+    response.push(comments);
+  }
+
+  if (msgctxt) {
+    response.push(this._addPOString('msgctxt', msgctxt));
+  }
+
+  response.push(this._addPOString('msgid', msgid || ''));
+
+  if (msgidPlural) {
+    response.push(this._addPOString('msgid_plural', msgidPlural));
+    msgstr.forEach(function (msgstr, i) {
+      response.push(this._addPOString('msgstr[' + i + ']', msgstr || ''));
+    }.bind(this));
+  } else {
+    response.push(this._addPOString('msgstr', msgstr[0] || ''));
+  }
+
+  return response.join('\n');
 };
 
 /**
@@ -116,72 +114,59 @@ Compiler.prototype._drawBlock = function(block, override) {
  * @param {String} value Key value
  * @return {String} Joined and escaped key-value pair
  */
-Compiler.prototype._addPOString = function(key, value) {
-    var line;
-
-    key = (key || '').toString();
+Compiler.prototype._addPOString = function (key, value) {
+  key = (key || '').toString();
 
     // escape newlines and quotes
-    value = (value || '').toString().
-    replace(/\\/g, '\\\\').
-    replace(/"/g, '\\"').
-    replace(/\t/g, '\\t').
-    replace(/\r/g, '\\r').
-    replace(/\n/g, '\\n');
-
-    var lines = sharedFuncs.foldLine(value);
-
-    if (lines.length < 2) {
-        return key + ' "' + (lines.shift() || '') + '"';
-    } else {
-        return key + ' ""\n"' + lines.join('"\n"') + '"';
-    }
-
-    if (value.match(/\n/)) {
-        value = value.replace(/\n/g, '\\n\n').replace(/\n$/, '');
-        line = ('\n' + value).split('\n').map(function(l) {
-            return '"' + l + '"';
-        }).join('\n');
-    } else {
-        line = '"' + value + '"';
-    }
-
-    return key + ' ' + line;
+  value = (value || '').toString()
+    .replace(/\\/g, '\\\\')
+    .replace(/"/g, '\\"')
+    .replace(/\t/g, '\\t')
+    .replace(/\r/g, '\\r')
+    .replace(/\n/g, '\\n');
+
+  var lines = sharedFuncs.foldLine(value);
+
+  if (lines.length < 2) {
+    return key + ' "' + (lines.shift() || '') + '"';
+  } else {
+    return key + ' ""\n"' + lines.join('"\n"') + '"';
+  }
 };
 
 /**
  * Handles header values, replaces or adds (if needed) a charset property
  */
-Compiler.prototype._handleCharset = function() {
-    var parts = (this._table.headers['content-type'] || 'text/plain').split(';');
-    var contentType = parts.shift();
-    var charset = sharedFuncs.formatCharset(this._table.charset);
-    var params = [];
-
-    params = parts.map(function(part) {
-        var parts = part.split('='),
-            key = parts.shift().trim(),
-            value = parts.join('=');
-
-        if (key.toLowerCase() === 'charset') {
-            if (!charset) {
-                charset = sharedFuncs.formatCharset(value.trim() || 'utf-8');
-            }
-            return 'charset=' + charset;
-        }
-
-        return part;
-    });
-
-    if (!charset) {
-        charset = this._table.charset || 'utf-8';
-        params.push('charset=' + charset);
+Compiler.prototype._handleCharset = function () {
+  var parts = (this._table.headers['content-type'] || 'text/plain').split(';');
+  var contentType = parts.shift();
+  var charset = sharedFuncs.formatCharset(this._table.charset);
+  var params = [];
+
+  params = parts.map(function (part) {
+    var parts = part.split('=');
+    var key = parts.shift().trim();
+    var value = parts.join('=');
+
+    if (key.toLowerCase() === 'charset') {
+      if (!charset) {
+        charset = sharedFuncs.formatCharset(value.trim() || 'utf-8');
+      }
+      return 'charset=' + charset;
     }
 
-    this._table.charset = charset;
-    this._table.headers['content-type'] = contentType + '; ' + params.join('; ');
+    return part;
+  });
+
+  if (!charset) {
+    charset = this._table.charset || 'utf-8';
+    params.push('charset=' + charset);
+  }
+
+  this._table.charset = charset;
+  this._table.headers['content-type'] = contentType + '; ' + params.join('; ');
 
-    this._charset = charset;
+  this._charset = charset;
 };
 
 /**
@@ -189,34 +174,33 @@ Compiler.prototype._handleCharset = function() {
  *
  * @return {Buffer} Compiled PO object
  */
-Compiler.prototype.compile = function() {
-
-    var response = [],
-        headerBlock = this._table.translations[''] && this._table.translations[''][''] || {};
-
-    response.push(this._drawBlock(headerBlock, {
-        msgstr: sharedFuncs.generateHeader(this._table.headers)
-    }));
-
-    Object.keys(this._table.translations).forEach((function(msgctxt) {
-        if (typeof this._table.translations[msgctxt] !== 'object') {
-            return;
-        }
-        Object.keys(this._table.translations[msgctxt]).forEach((function(msgid) {
-            if (typeof this._table.translations[msgctxt][msgid] !== 'object') {
-                return;
-            }
-            if (msgctxt === '' && msgid === '') {
-                return;
-            }
-
-            response.push(this._drawBlock(this._table.translations[msgctxt][msgid]));
-        }).bind(this));
-    }).bind(this));
-
-    if (this._charset === 'utf-8' || this._charset === 'ascii') {
-        return new Buffer(response.join('\n\n'), 'utf-8');
-    } else {
-        return encoding.convert(response.join('\n\n'), this._charset);
+Compiler.prototype.compile = function () {
+  var response = [];
+  var headerBlock = this._table.translations[''] && this._table.translations[''][''] || {};
+
+  response.push(this._drawBlock(headerBlock, {
+    msgstr: sharedFuncs.generateHeader(this._table.headers)
+  }));
+
+  Object.keys(this._table.translations).forEach(function (msgctxt) {
+    if (typeof this._table.translations[msgctxt] !== 'object') {
+      return;
     }
+    Object.keys(this._table.translations[msgctxt]).forEach(function (msgid) {
+      if (typeof this._table.translations[msgctxt][msgid] !== 'object') {
+        return;
+      }
+      if (msgctxt === '' && msgid === '') {
+        return;
+      }
+
+      response.push(this._drawBlock(this._table.translations[msgctxt][msgid]));
+    }.bind(this));
+  }.bind(this));
+
+  if (this._charset === 'utf-8' || this._charset === 'ascii') {
+    return new Buffer(response.join('\n\n'), 'utf-8');
+  } else {
+    return encoding.convert(response.join('\n\n'), this._charset);
+  }
 };
diff --git a/lib/poparser.js b/lib/poparser.js
index e215bca..15a379f 100644
--- a/lib/poparser.js
+++ b/lib/poparser.js
@@ -12,9 +12,9 @@ var util = require('util');
  * @param {String} [defaultCharset] Default charset to use
  * @return {Object} Translation object
  */
-module.exports.parse = function(buffer, defaultCharset) {
-    var parser = new Parser(buffer, defaultCharset);
-    return parser.parse();
+module.exports.parse = function (buffer, defaultCharset) {
+  var parser = new Parser(buffer, defaultCharset);
+  return parser.parse();
 };
 
 /**
@@ -24,8 +24,8 @@ module.exports.parse = function(buffer, defaultCharset) {
  * @param {String} [options] Stream options
  * @return {Stream} Transform stream
  */
-module.exports.stream = function(defaultCharset, options) {
-    return new PoParserTransform(defaultCharset, options);
+module.exports.stream = function (defaultCharset, options) {
+  return new PoParserTransform(defaultCharset, options);
 };
 
 /**
@@ -36,21 +36,20 @@ module.exports.stream = function(defaultCharset, options) {
  * @param {Buffer|String} fileContents PO object
  * @param {String} [defaultCharset] Default charset to use
  */
-function Parser(fileContents, defaultCharset) {
-
-    this._charset = defaultCharset || 'iso-8859-1';
-
-    this._lex = [];
-    this._escaped = false;
-    this._node;
-    this._state = this.states.none;
-
-    if (typeof fileContents === 'string') {
-        this._charset = 'utf-8';
-        this._fileContents = fileContents;
-    } else {
-        this._handleCharset(fileContents);
-    }
+function Parser (fileContents, defaultCharset) {
+  this._charset = defaultCharset || 'iso-8859-1';
+
+  this._lex = [];
+  this._escaped = false;
+  this._node;
+  this._state = this.states.none;
+
+  if (typeof fileContents === 'string') {
+    this._charset = 'utf-8';
+    this._fileContents = fileContents;
+  } else {
+    this._handleCharset(fileContents);
+  }
 }
 
 /**
@@ -58,9 +57,9 @@ function Parser(fileContents, defaultCharset) {
  *
  * @return {Object} Translation table
  */
-Parser.prototype.parse = function() {
-    this._lexer(this._fileContents);
-    return this._finalize(this._lex);
+Parser.prototype.parse = function () {
+  this._lexer(this._fileContents);
+  return this._finalize(this._lex);
 };
 
 /**
@@ -68,59 +67,60 @@ Parser.prototype.parse = function() {
  *
  * @param {Buffer} headers Header value
  */
-Parser.prototype._handleCharset = function(buf) {
-    var str = (buf || '').toString(),
-        pos, headers = '',
-        match;
-
-    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);
-        }
+Parser.prototype._handleCharset = function (buf) {
+  var str = (buf || '').toString();
+  var pos;
+  var headers = '';
+  var match;
+
+  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);
     }
+  }
 
-    if ((match = headers.match(/[; ]charset\s*=\s*([\w\-]+)(?:[\s;]|\\n)*"\s*$/mi))) {
-        this._charset = sharedFuncs.formatCharset(match[1], this._charset);
-    }
+  if ((match = headers.match(/[; ]charset\s*=\s*([\w-]+)(?:[\s;]|\\n)*"\s*$/mi))) {
+    this._charset = sharedFuncs.formatCharset(match[1], this._charset);
+  }
 
-    if (this._charset === 'utf-8') {
-        this._fileContents = str;
-    } else {
-        this._fileContents = this._toString(buf);
-    }
+  if (this._charset === 'utf-8') {
+    this._fileContents = str;
+  } else {
+    this._fileContents = this._toString(buf);
+  }
 };
 
-Parser.prototype._toString = function(buf) {
-    return encoding.convert(buf, 'utf-8', this._charset).toString('utf-8');
+Parser.prototype._toString = function (buf) {
+  return encoding.convert(buf, 'utf-8', this._charset).toString('utf-8');
 };
 
 /**
  * State constants for parsing FSM
  */
 Parser.prototype.states = {
-    none: 0x01,
-    comments: 0x02,
-    key: 0x03,
-    string: 0x04
+  none: 0x01,
+  comments: 0x02,
+  key: 0x03,
+  string: 0x04
 };
 
 /**
  * Value types for lexer
  */
 Parser.prototype.types = {
-    comments: 0x01,
-    key: 0x02,
-    string: 0x03
+  comments: 0x01,
+  key: 0x02,
+  string: 0x03
 };
 
 /**
  * String matches for lexer
  */
 Parser.prototype.symbols = {
-    quotes: /["']/,
-    comments: /\#/,
-    whitespace: /\s/,
-    key: /[\w\-\[\]]/
+  quotes: /["']/,
+  comments: /#/,
+  whitespace: /\s/,
+  key: /[\w\-[\]]/
 };
 
 /**
@@ -128,82 +128,82 @@ Parser.prototype.symbols = {
  *
  * @param {String} chunk String
  */
-Parser.prototype._lexer = function(chunk) {
-    var chr;
-
-    for (var i = 0, len = chunk.length; i < len; i++) {
-        chr = chunk.charAt(i);
-        switch (this._state) {
-            case this.states.none:
-                if (chr.match(this.symbols.quotes)) {
-                    this._node = {
-                        type: this.types.string,
-                        value: '',
-                        quote: chr
-                    };
-                    this._lex.push(this._node);
-                    this._state = this.states.string;
-                } else if (chr.match(this.symbols.comments)) {
-                    this._node = {
-                        type: this.types.comments,
-                        value: ''
-                    };
-                    this._lex.push(this._node);
-                    this._state = this.states.comments;
-                } else if (!chr.match(this.symbols.whitespace)) {
-                    this._node = {
-                        type: this.types.key,
-                        value: chr
-                    };
-                    this._lex.push(this._node);
-                    this._state = this.states.key;
-                }
-                break;
-            case this.states.comments:
-                if (chr === '\n') {
-                    this._state = this.states.none;
-                } else if (chr !== '\r') {
-                    this._node.value += chr;
-                }
-                break;
-            case this.states.string:
-                if (this._escaped) {
-                    switch (chr) {
-                        case 't':
-                            this._node.value += '\t';
-                            break;
-                        case 'n':
-                            this._node.value += '\n';
-                            break;
-                        case 'r':
-                            this._node.value += '\r';
-                            break;
-                        default:
-                            this._node.value += chr;
-                    }
-                    this._escaped = false;
-                } else {
-                    if (chr === this._node.quote) {
-                        this._state = this.states.none;
-                    } else if (chr === '\\') {
-                        this._escaped = true;
-                        break;
-                    } else {
-                        this._node.value += chr;
-                    }
-                    this._escaped = false;
-                }
-                break;
-            case this.states.key:
-                if (!chr.match(this.symbols.key)) {
-                    this._state = this.states.none;
-                    i--;
-                } else {
-                    this._node.value += chr;
-                }
-                break;
+Parser.prototype._lexer = function (chunk) {
+  var chr;
+
+  for (var i = 0, len = chunk.length; i < len; i++) {
+    chr = chunk.charAt(i);
+    switch (this._state) {
+      case this.states.none:
+        if (chr.match(this.symbols.quotes)) {
+          this._node = {
+            type: this.types.string,
+            value: '',
+            quote: chr
+          };
+          this._lex.push(this._node);
+          this._state = this.states.string;
+        } else if (chr.match(this.symbols.comments)) {
+          this._node = {
+            type: this.types.comments,
+            value: ''
+          };
+          this._lex.push(this._node);
+          this._state = this.states.comments;
+        } else if (!chr.match(this.symbols.whitespace)) {
+          this._node = {
+            type: this.types.key,
+            value: chr
+          };
+          this._lex.push(this._node);
+          this._state = this.states.key;
+        }
+        break;
+      case this.states.comments:
+        if (chr === '\n') {
+          this._state = this.states.none;
+        } else if (chr !== '\r') {
+          this._node.value += chr;
+        }
+        break;
+      case this.states.string:
+        if (this._escaped) {
+          switch (chr) {
+            case 't':
+              this._node.value += '\t';
+              break;
+            case 'n':
+              this._node.value += '\n';
+              break;
+            case 'r':
+              this._node.value += '\r';
+              break;
+            default:
+              this._node.value += chr;
+          }
+          this._escaped = false;
+        } else {
+          if (chr === this._node.quote) {
+            this._state = this.states.none;
+          } else if (chr === '\\') {
+            this._escaped = true;
+            break;
+          } else {
+            this._node.value += chr;
+          }
+          this._escaped = false;
+        }
+        break;
+      case this.states.key:
+        if (!chr.match(this.symbols.key)) {
+          this._state = this.states.none;
+          i--;
+        } else {
+          this._node.value += chr;
         }
+        break;
     }
+  }
 };
 
 /**
@@ -212,21 +212,22 @@ Parser.prototype._lexer = function(chunk) {
  * @param {Object} tokens Parsed tokens
  * @return {Object} Parsed tokens, with multi line strings joined into one
  */
-Parser.prototype._joinStringValues = function(tokens) {
-    var lastNode, response = [];
-
-    for (var i = 0, len = tokens.length; i < len; i++) {
-        if (lastNode && tokens[i].type === this.types.string && lastNode.type === this.types.string) {
-            lastNode.value += tokens[i].value;
-        } else if (lastNode && tokens[i].type === this.types.comments && lastNode.type === this.types.comments) {
-            lastNode.value += '\n' + tokens[i].value;
-        } else {
-            response.push(tokens[i]);
-            lastNode = tokens[i];
-        }
+Parser.prototype._joinStringValues = function (tokens) {
+  var lastNode;
+  var response = [];
+
+  for (var i = 0, len = tokens.length; i < len; i++) {
+    if (lastNode && tokens[i].type === this.types.string && lastNode.type === this.types.string) {
+      lastNode.value += tokens[i].value;
+    } else if (lastNode && tokens[i].type === this.types.comments && lastNode.type === this.types.comments) {
+      lastNode.value += '\n' + tokens[i].value;
+    } else {
+      response.push(tokens[i]);
+      lastNode = tokens[i];
     }
+  }
 
-    return response;
+  return response;
 };
 
 /**
@@ -234,48 +235,48 @@ Parser.prototype._joinStringValues = function(tokens) {
  *
  * @param {Object} tokens Parsed tokens
  */
-Parser.prototype._parseComments = function(tokens) {
+Parser.prototype._parseComments = function (tokens) {
     // parse comments
-    tokens.forEach((function(node) {
-        var comment, lines;
-
-        if (node && node.type === this.types.comments) {
-            comment = {
-                translator: [],
-                extracted: [],
-                reference: [],
-                flag: [],
-                previous: []
-            };
-            lines = (node.value || '').split(/\n/);
-            lines.forEach(function(line) {
-                switch (line.charAt(0) || '') {
-                    case ':':
-                        comment.reference.push(line.substr(1).trim());
-                        break;
-                    case '.':
-                        comment.extracted.push(line.substr(1).replace(/^\s+/, ''));
-                        break;
-                    case ',':
-                        comment.flag.push(line.substr(1).replace(/^\s+/, ''));
-                        break;
-                    case '|':
-                        comment.previous.push(line.substr(1).replace(/^\s+/, ''));
-                        break;
-                    default:
-                        comment.translator.push(line.replace(/^\s+/, ''));
-                }
-            });
-
-            node.value = {};
-
-            Object.keys(comment).forEach(function(key) {
-                if (comment[key] && comment[key].length) {
-                    node.value[key] = comment[key].join('\n');
-                }
-            });
+  tokens.forEach(function (node) {
+    var comment, lines;
+
+    if (node && node.type === this.types.comments) {
+      comment = {
+        translator: [],
+        extracted: [],
+        reference: [],
+        flag: [],
+        previous: []
+      };
+      lines = (node.value || '').split(/\n/);
+      lines.forEach(function (line) {
+        switch (line.charAt(0) || '') {
+          case ':':
+            comment.reference.push(line.substr(1).trim());
+            break;
+          case '.':
+            comment.extracted.push(line.substr(1).replace(/^\s+/, ''));
+            break;
+          case ',':
+            comment.flag.push(line.substr(1).replace(/^\s+/, ''));
+            break;
+          case '|':
+            comment.previous.push(line.substr(1).replace(/^\s+/, ''));
+            break;
+          default:
+            comment.translator.push(line.replace(/^\s+/, ''));
+        }
+      });
+
+      node.value = {};
+
+      Object.keys(comment).forEach(function (key) {
+        if (comment[key] && comment[key].length) {
+          node.value[key] = comment[key].join('\n');
         }
-    }).bind(this));
+      });
+    }
+  }.bind(this));
 };
 
 /**
@@ -284,26 +285,26 @@ Parser.prototype._parseComments = function(tokens) {
  * @param {Object} tokens Parsed tokens
  * @return {Object} Tokens
  */
-Parser.prototype._handleKeys = function(tokens) {
-    var response = [],
-        lastNode;
-
-    for (var i = 0, len = tokens.length; i < len; i++) {
-        if (tokens[i].type === this.types.key) {
-            lastNode = {
-                key: tokens[i].value
-            };
-            if (i && tokens[i - 1].type === this.types.comments) {
-                lastNode.comments = tokens[i - 1].value;
-            }
-            lastNode.value = '';
-            response.push(lastNode);
-        } else if (tokens[i].type === this.types.string && lastNode) {
-            lastNode.value += tokens[i].value;
-        }
+Parser.prototype._handleKeys = function (tokens) {
+  var response = [];
+  var lastNode;
+
+  for (var i = 0, len = tokens.length; i < len; i++) {
+    if (tokens[i].type === this.types.key) {
+      lastNode = {
+        key: tokens[i].value
+      };
+      if (i && tokens[i - 1].type === this.types.comments) {
+        lastNode.comments = tokens[i - 1].value;
+      }
+      lastNode.value = '';
+      response.push(lastNode);
+    } else if (tokens[i].type === this.types.string && lastNode) {
+      lastNode.value += tokens[i].value;
     }
+  }
 
-    return response;
+  return response;
 };
 
 /**
@@ -312,60 +313,62 @@ Parser.prototype._handleKeys = function(tokens) {
  * @param {Object} tokens Parsed tokens
  * @return {Object} Tokens
  */
-Parser.prototype._handleValues = function(tokens) {
-    var response = [],
-        lastNode, curContext, curComments;
-
-    for (var i = 0, len = tokens.length; i < len; i++) {
-        if (tokens[i].key.toLowerCase() === 'msgctxt') {
-            curContext = tokens[i].value;
-            curComments = tokens[i].comments;
-        } else if (tokens[i].key.toLowerCase() === 'msgid') {
-            lastNode = {
-                msgid: tokens[i].value
-            };
-
-            if (curContext) {
-                lastNode.msgctxt = curContext;
-            }
-
-            if (curComments) {
-                lastNode.comments = curComments;
-            }
-
-            if (tokens[i].comments && !lastNode.comments) {
-                lastNode.comments = tokens[i].comments;
-            }
-
-            curContext = false;
-            curComments = false;
-            response.push(lastNode);
-        } else if (tokens[i].key.toLowerCase() === 'msgid_plural') {
-            if (lastNode) {
-                lastNode.msgid_plural = tokens[i].value;
-            }
-
-            if (tokens[i].comments && !lastNode.comments) {
-                lastNode.comments = tokens[i].comments;
-            }
-
-            curContext = false;
-            curComments = false;
-        } else if (tokens[i].key.substr(0, 6).toLowerCase() === 'msgstr') {
-            if (lastNode) {
-                lastNode.msgstr = (lastNode.msgstr || []).concat(tokens[i].value);
-            }
-
-            if (tokens[i].comments && !lastNode.comments) {
-                lastNode.comments = tokens[i].comments;
-            }
-
-            curContext = false;
-            curComments = false;
-        }
+Parser.prototype._handleValues = function (tokens) {
+  var response = [];
+  var lastNode;
+  var curContext;
+  var curComments;
+
+  for (var i = 0, len = tokens.length; i < len; i++) {
+    if (tokens[i].key.toLowerCase() === 'msgctxt') {
+      curContext = tokens[i].value;
+      curComments = tokens[i].comments;
+    } else if (tokens[i].key.toLowerCase() === 'msgid') {
+      lastNode = {
+        msgid: tokens[i].value
+      };
+
+      if (curContext) {
+        lastNode.msgctxt = curContext;
+      }
+
+      if (curComments) {
+        lastNode.comments = curComments;
+      }
+
+      if (tokens[i].comments && !lastNode.comments) {
+        lastNode.comments = tokens[i].comments;
+      }
+
+      curContext = false;
+      curComments = false;
+      response.push(lastNode);
+    } else if (tokens[i].key.toLowerCase() === 'msgid_plural') {
+      if (lastNode) {
+        lastNode.msgid_plural = tokens[i].value;
+      }
+
+      if (tokens[i].comments && !lastNode.comments) {
+        lastNode.comments = tokens[i].comments;
+      }
+
+      curContext = false;
+      curComments = false;
+    } else if (tokens[i].key.substr(0, 6).toLowerCase() === 'msgstr') {
+      if (lastNode) {
+        lastNode.msgstr = (lastNode.msgstr || []).concat(tokens[i].value);
+      }
+
+      if (tokens[i].comments && !lastNode.comments) {
+        lastNode.comments = tokens[i].comments;
+      }
+
+      curContext = false;
+      curComments = false;
     }
+  }
 
-    return response;
+  return response;
 };
 
 /**
@@ -374,29 +377,29 @@ Parser.prototype._handleValues = function(tokens) {
  * @param {Object} tokens Parsed tokens
  * @return {Object} Translation table
  */
-Parser.prototype._normalize = function(tokens) {
-    var msgctxt,
-        table = {
-            charset: this._charset,
-            headers: undefined,
-            translations: {}
-        };
-
-    for (var i = 0, len = tokens.length; i < len; i++) {
-        msgctxt = tokens[i].msgctxt || '';
-
-        if (!table.translations[msgctxt]) {
-            table.translations[msgctxt] = {};
-        }
-
-        if (!table.headers && !msgctxt && !tokens[i].msgid) {
-            table.headers = sharedFuncs.parseHeader(tokens[i].msgstr[0]);
-        }
+Parser.prototype._normalize = function (tokens) {
+  var msgctxt;
+  var table = {
+    charset: this._charset,
+    headers: undefined,
+    translations: {}
+  };
+
+  for (var i = 0, len = tokens.length; i < len; i++) {
+    msgctxt = tokens[i].msgctxt || '';
+
+    if (!table.translations[msgctxt]) {
+      table.translations[msgctxt] = {};
+    }
 
-        table.translations[msgctxt][tokens[i].msgid] = tokens[i];
+    if (!table.headers && !msgctxt && !tokens[i].msgid) {
+      table.headers = sharedFuncs.parseHeader(tokens[i].msgstr[0]);
     }
 
-    return table;
+    table.translations[msgctxt][tokens[i].msgid] = tokens[i];
+  }
+
+  return table;
 };
 
 /**
@@ -405,13 +408,13 @@ Parser.prototype._normalize = function(tokens) {
  * @param {Object} tokens Parsed tokens
  * @returns {Object} Translation table
  */
-Parser.prototype._finalize = function(tokens) {
-    var data = this._joinStringValues(tokens);
-    this._parseComments(data);
-    data = this._handleKeys(data);
-    data = this._handleValues(data);
+Parser.prototype._finalize = function (tokens) {
+  var data = this._joinStringValues(tokens);
+  this._parseComments(data);
+  data = this._handleKeys(data);
+  data = this._handleValues(data);
 
-    return this._normalize(data);
+  return this._normalize(data);
 };
 
 /**
@@ -421,105 +424,106 @@ Parser.prototype._finalize = function(tokens) {
  * @param {String} [defaultCharset] Default charset to use
  * @param {String} [options] Stream options
  */
-function PoParserTransform(defaultCharset, options) {
-    if (!options && defaultCharset && typeof defaultCharset === 'object') {
-        options = defaultCharset;
-        defaultCharset = undefined;
-    }
+function PoParserTransform (defaultCharset, options) {
+  if (!options && defaultCharset && typeof defaultCharset === 'object') {
+    options = defaultCharset;
+    defaultCharset = undefined;
+  }
 
-    this.defaultCharset = defaultCharset;
-    this._parser = false;
-    this._tokens = {};
+  this.defaultCharset = defaultCharset;
+  this._parser = false;
+  this._tokens = {};
 
-    this._cache = [];
-    this._cacheSize = 0;
+  this._cache = [];
+  this._cacheSize = 0;
 
-    this.initialTreshold = options.initialTreshold || 2 * 1024;
+  this.initialTreshold = options.initialTreshold || 2 * 1024;
 
-    Transform.call(this, options);
-    this._writableState.objectMode = false;
-    this._readableState.objectMode = true;
+  Transform.call(this, options);
+  this._writableState.objectMode = false;
+  this._readableState.objectMode = true;
 }
 util.inherits(PoParserTransform, Transform);
 
 /**
  * Processes a chunk of the input stream
  */
-PoParserTransform.prototype._transform = function(chunk, encoding, done) {
-    var i, len = 0;
+PoParserTransform.prototype._transform = function (chunk, encoding, done) {
+  var i;
+  var len = 0;
 
-    if (!chunk || !chunk.length) {
-        return done();
-    }
+  if (!chunk || !chunk.length) {
+    return done();
+  }
 
-    if (!this._parser) {
-        this._cache.push(chunk);
-        this._cacheSize += chunk.length;
+  if (!this._parser) {
+    this._cache.push(chunk);
+    this._cacheSize += chunk.length;
 
         // wait until the first 1kb before parsing headers for charset
-        if (this._cacheSize < this.initialTreshold) {
-            return setImmediate(done);
-        } else if (this._cacheSize) {
-            chunk = Buffer.concat(this._cache, this._cacheSize);
-            this._cacheSize = 0;
-            this._cache = [];
-        }
-
-        this._parser = new Parser(chunk, this.defaultCharset);
+    if (this._cacheSize < this.initialTreshold) {
+      return setImmediate(done);
     } else if (this._cacheSize) {
-        // this only happens if we had an uncompleted 8bit sequence from the last iteration
-        this._cache.push(chunk);
-        this._cacheSize += chunk.length;
-        chunk = Buffer.concat(this._cache, this._cacheSize);
-        this._cacheSize = 0;
-        this._cache = [];
+      chunk = Buffer.concat(this._cache, this._cacheSize);
+      this._cacheSize = 0;
+      this._cache = [];
     }
 
+    this._parser = new Parser(chunk, this.defaultCharset);
+  } else if (this._cacheSize) {
+        // this only happens if we had an uncompleted 8bit sequence from the last iteration
+    this._cache.push(chunk);
+    this._cacheSize += chunk.length;
+    chunk = Buffer.concat(this._cache, this._cacheSize);
+    this._cacheSize = 0;
+    this._cache = [];
+  }
+
     // cache 8bit bytes from the end of the chunk
     // helps if the chunk ends in the middle of an utf-8 sequence
-    for (i = chunk.length - 1; i >= 0; i--) {
-        if (chunk[i] >= 0x80) {
-            len++;
-            continue;
-        }
-        break;
+  for (i = chunk.length - 1; i >= 0; i--) {
+    if (chunk[i] >= 0x80) {
+      len++;
+      continue;
     }
+    break;
+  }
     // it seems we found some 8bit bytes from the end of the string, so let's cache these
-    if (len) {
-        this._cache = [chunk.slice(chunk.length - len)];
-        this._cacheSize = this._cache[0].length;
-        chunk = chunk.slice(0, chunk.length - len);
-    }
+  if (len) {
+    this._cache = [chunk.slice(chunk.length - len)];
+    this._cacheSize = this._cache[0].length;
+    chunk = chunk.slice(0, chunk.length - len);
+  }
 
     // chunk might be empty if it only contined of 8bit bytes and these were all cached
-    if (chunk.length) {
-        this._parser._lexer(this._parser._toString(chunk));
-    }
+  if (chunk.length) {
+    this._parser._lexer(this._parser._toString(chunk));
+  }
 
-    setImmediate(done);
+  setImmediate(done);
 };
 
 /**
  * Once all input has been processed emit the parsed translation table as an object
  */
-PoParserTransform.prototype._flush = function(done) {
-    var chunk;
+PoParserTransform.prototype._flush = function (done) {
+  var chunk;
 
-    if (this._cacheSize) {
-        chunk = Buffer.concat(this._cache, this._cacheSize);
-    }
+  if (this._cacheSize) {
+    chunk = Buffer.concat(this._cache, this._cacheSize);
+  }
 
-    if (!this._parser && chunk) {
-        this._parser = new Parser(chunk, this.defaultCharset);
-    }
+  if (!this._parser && chunk) {
+    this._parser = new Parser(chunk, this.defaultCharset);
+  }
 
-    if (chunk) {
-        this._parser._lexer(this._parser._toString(chunk));
-    }
+  if (chunk) {
+    this._parser._lexer(this._parser._toString(chunk));
+  }
 
-    if (this._parser) {
-        this.push(this._parser._finalize(this._parser._lex));
-    }
+  if (this._parser) {
+    this.push(this._parser._finalize(this._parser._lex));
+  }
 
-    setImmediate(done);
-};
\ No newline at end of file
+  setImmediate(done);
+};
diff --git a/lib/shared.js b/lib/shared.js
index 44bfb86..a8d0e50 100644
--- a/lib/shared.js
+++ b/lib/shared.js
@@ -12,21 +12,21 @@ module.exports.foldLine = foldLine;
  * @param {String} str Header string
  * @return {Object} An object of key-value pairs
  */
-function parseHeader(str) {
-    var lines = (str || '').split('\n'),
-        headers = {};
-
-    lines.forEach(function(line) {
-        var parts = line.trim().split(':'),
-            key = (parts.shift() || '').trim().toLowerCase(),
-            value = parts.join(':').trim();
-        if (!key) {
-            return;
-        }
-        headers[key] = value;
-    });
+function parseHeader (str) {
+  var lines = (str || '').split('\n');
+  var headers = {};
+
+  lines.forEach(function (line) {
+    var parts = line.trim().split(':');
+    var key = (parts.shift() || '').trim().toLowerCase();
+    var value = parts.join(':').trim();
+    if (!key) {
+      return;
+    }
+    headers[key] = value;
+  });
 
-    return headers;
+  return headers;
 }
 
 /**
@@ -35,9 +35,12 @@ function parseHeader(str) {
  * @param {String} str String to be updated
  * @return {String} A string with uppercase words
  */
-function upperCaseWords(str) {
-    return (str || '').toLowerCase().trim().replace(/^(MIME|POT?(?=\-)|[a-z])|\-[a-z]/gi, function(str) {
-        return str.toUpperCase();
+function upperCaseWords (str) {
+  return (str || '')
+    .toLowerCase()
+    .trim()
+    .replace(/^(MIME|POT?(?=-)|[a-z])|-[a-z]/gi, function (str) {
+      return str.toUpperCase();
     });
 }
 
@@ -47,16 +50,16 @@ function upperCaseWords(str) {
  * @param {Object} header Object of key value pairs
  * @return {String} Header string
  */
-function generateHeader(header) {
-    var lines = [];
+function generateHeader (header) {
+  var lines = [];
 
-    Object.keys(header || {}).forEach(function(key) {
-        if (key) {
-            lines.push(upperCaseWords(key) + ': ' + (header[key] || '').trim());
-        }
-    });
+  Object.keys(header || {}).forEach(function (key) {
+    if (key) {
+      lines.push(upperCaseWords(key) + ': ' + (header[key] || '').trim());
+    }
+  });
 
-    return lines.join('\n') + (lines.length ? '\n' : '');
+  return lines.join('\n') + (lines.length ? '\n' : '');
 }
 
 /**
@@ -65,14 +68,14 @@ function generateHeader(header) {
  * @param {String} charset Charset name
  * @return {String} Normalized charset name
  */
-function formatCharset(charset, defaultCharset) {
-    return (charset || 'iso-8859-1').toString().toLowerCase().
-    replace(/^utf[\-_]?(\d+)$/, 'utf-$1').
-    replace(/^win(?:dows)?[\-_]?(\d+)$/, 'windows-$1').
-    replace(/^latin[\-_]?(\d+)$/, 'iso-8859-$1').
-    replace(/^(us[\-_]?)?ascii$/, 'ascii').
-    replace(/^charset$/, defaultCharset || 'iso-8859-1').
-    trim();
+function formatCharset (charset, defaultCharset) {
+  return (charset || 'iso-8859-1').toString().toLowerCase()
+    .replace(/^utf[-_]?(\d+)$/, 'utf-$1')
+    .replace(/^win(?:dows)?[-_]?(\d+)$/, 'windows-$1')
+    .replace(/^latin[-_]?(\d+)$/, 'iso-8859-$1')
+    .replace(/^(us[-_]?)?ascii$/, 'ascii')
+    .replace(/^charset$/, defaultCharset || 'iso-8859-1')
+    .trim();
 }
 
 /**
@@ -82,39 +85,38 @@ function formatCharset(charset, defaultCharset) {
  * @param {Number} [maxLen=76] Maximum allowed length for folded lines
  * @return {Array} An array of lines
  */
-function foldLine(str, maxLen) {
+function foldLine (str, maxLen) {
+  maxLen = maxLen || 76;
 
-    maxLen = maxLen || 76;
+  var lines = [];
+  var curLine = '';
+  var pos = 0;
+  var len = str.length;
+  var match;
 
-    var lines = [],
-        curLine = '',
-        pos = 0,
-        len = str.length,
-        match;
-
-    while (pos < len) {
-        curLine = str.substr(pos, maxLen);
+  while (pos < len) {
+    curLine = str.substr(pos, maxLen);
 
         // ensure that the line never ends with a partial escaping
         // make longer lines if needed
-        while (curLine.substr(-1) === '\\' && pos + curLine.length < len) {
-            curLine += str.charAt(pos + curLine.length);
-        }
+    while (curLine.substr(-1) === '\\' && pos + curLine.length < len) {
+      curLine += str.charAt(pos + curLine.length);
+    }
 
         // ensure that if possible, line breaks are done at reasonable places
-        if ((match = curLine.match(/\\n/))) {
-            curLine = curLine.substr(0, match.index + 2);
-        } else if (pos + curLine.length < len) {
-            if ((match = curLine.match(/(\s+)[^\s]*$/)) && match.index > 0) {
-                curLine = curLine.substr(0, match.index + match[1].length);
-            } else if ((match = curLine.match(/([\x21-\x40\x5b-\x60\x7b-\x7e]+)[^\x21-\x40\x5b-\x60\x7b-\x7e]*$/)) && match.index > 0) {
-                curLine = curLine.substr(0, match.index + match[1].length);
-            }
-        }
-
-        lines.push(curLine);
-        pos += curLine.length;
+    if ((match = curLine.match(/\\n/))) {
+      curLine = curLine.substr(0, match.index + 2);
+    } else if (pos + curLine.length < len) {
+      if ((match = curLine.match(/(\s+)[^\s]*$/)) && match.index > 0) {
+        curLine = curLine.substr(0, match.index + match[1].length);
+      } else if ((match = curLine.match(/([\x21-\x40\x5b-\x60\x7b-\x7e]+)[^\x21-\x40\x5b-\x60\x7b-\x7e]*$/)) && match.index > 0) {
+        curLine = curLine.substr(0, match.index + match[1].length);
+      }
     }
 
-    return lines;
-}
\ No newline at end of file
+    lines.push(curLine);
+    pos += curLine.length;
+  }
+
+  return lines;
+}
diff --git a/package.json b/package.json
index 8b2436d..66c1e8c 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "gettext-parser",
   "description": "Parse and compile gettext po and mo files to/from json, nothing more, nothing less",
-  "version": "1.2.1",
+  "version": "1.2.2",
   "author": "Andris Reinman",
   "contributors": [
     {
@@ -14,8 +14,9 @@
     "url": "http://github.com/smhg/gettext-parser.git"
   },
   "scripts": {
-    "test": "grunt",
-    "preversion": "npm test",
+    "lint": "eslint lib/*.js test/*.js index.js",
+    "test": "mocha",
+    "preversion": "npm run lint && npm test",
     "postversion": "git push && git push --tags"
   },
   "main": "./index",
@@ -25,10 +26,10 @@
   },
   "devDependencies": {
     "chai": "3.5.0",
-    "grunt": "1.0.1",
-    "grunt-cli": "1.2.0",
-    "grunt-contrib-jshint": "1.1.0",
-    "grunt-mocha-test": "0.13.2",
+    "eslint": "3.13.1",
+    "eslint-config-standard": "6.2.1",
+    "eslint-plugin-promise": "3.4.0",
+    "eslint-plugin-standard": "2.0.1",
     "mocha": "3.2.0"
   },
   "keywords": [
diff --git a/test/.eslintrc.json b/test/.eslintrc.json
new file mode 100644
index 0000000..f9fbb2d
--- /dev/null
+++ b/test/.eslintrc.json
@@ -0,0 +1,5 @@
+{
+    "env": {
+        "mocha": true
+    }
+}
\ No newline at end of file
diff --git a/test/folder-test.js b/test/folder-test.js
index 7f1bbec..14bb4b8 100644
--- a/test/folder-test.js
+++ b/test/folder-test.js
@@ -6,35 +6,33 @@ var sharedFuncs = require('../lib/shared');
 var expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('Folding tests', function() {
-
-    it('Short line, no folding', function() {
-        var line = 'abc def ghi';
-        var folded = sharedFuncs.foldLine(line);
-
-        expect(line).to.equal(folded.join(''));
-        expect(folded.length).to.equal(1);
-    });
-
-    it('Short line, force fold with newline', function() {
-        var line = 'abc \\ndef \\nghi';
-        var folded = sharedFuncs.foldLine(line);
-
-        expect(line).to.equal(folded.join(''));
-        expect(folded).to.deep.equal(['abc \\n', 'def \\n', 'ghi']);
-    });
-
-    it('Long line', function() {
-        var expected = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pretium ',
-            'a nunc ac fringilla. Nulla laoreet tincidunt tincidunt. Proin tristique ',
-            'vestibulum mauris non aliquam. Vivamus volutpat odio nisl, sed placerat ',
-            'turpis sodales a. Vestibulum quis lectus ac elit sagittis sodales ac a ',
-            'felis. Nulla iaculis, nisl ut mattis fringilla, tortor quam tincidunt ',
-            'lorem, quis feugiat purus felis ut velit. Donec euismod eros ut leo ',
-            'lobortis tristique.'
-        ];
-        var folded = sharedFuncs.foldLine(expected.join(''));
-        expect(folded).to.deep.equal(expected);
-    });
-
-});
\ No newline at end of file
+describe('Folding tests', function () {
+  it('Short line, no folding', function () {
+    var line = 'abc def ghi';
+    var folded = sharedFuncs.foldLine(line);
+
+    expect(line).to.equal(folded.join(''));
+    expect(folded.length).to.equal(1);
+  });
+
+  it('Short line, force fold with newline', function () {
+    var line = 'abc \\ndef \\nghi';
+    var folded = sharedFuncs.foldLine(line);
+
+    expect(line).to.equal(folded.join(''));
+    expect(folded).to.deep.equal(['abc \\n', 'def \\n', 'ghi']);
+  });
+
+  it('Long line', function () {
+    var expected = ['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pretium ',
+      'a nunc ac fringilla. Nulla laoreet tincidunt tincidunt. Proin tristique ',
+      'vestibulum mauris non aliquam. Vivamus volutpat odio nisl, sed placerat ',
+      'turpis sodales a. Vestibulum quis lectus ac elit sagittis sodales ac a ',
+      'felis. Nulla iaculis, nisl ut mattis fringilla, tortor quam tincidunt ',
+      'lorem, quis feugiat purus felis ut velit. Donec euismod eros ut leo ',
+      'lobortis tristique.'
+    ];
+    var folded = sharedFuncs.foldLine(expected.join(''));
+    expect(folded).to.deep.equal(expected);
+  });
+});
diff --git a/test/mo-compiler-test.js b/test/mo-compiler-test.js
index 77b820f..f32083f 100644
--- a/test/mo-compiler-test.js
+++ b/test/mo-compiler-test.js
@@ -3,28 +3,28 @@
 var chai = require('chai');
 var gettextParser = require('..');
 var fs = require('fs');
+var path = require('path');
 
 var expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('MO Compiler', function() {
+describe('MO Compiler', function () {
+  describe('UTF-8', function () {
+    it('should compile', function () {
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/utf8-mo.json'), 'utf-8'));
+      var mo = fs.readFileSync(path.join(__dirname, 'fixtures/utf8.mo'));
 
-    describe('UTF-8', function() {
-        it('should compile', function() {
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-mo.json', 'utf-8'));
-            var mo = fs.readFileSync(__dirname + '/fixtures/utf8.mo');
-
-            var compiled = gettextParser.mo.compile(json);
-            expect(compiled).to.deep.equal(mo);
-        });
+      var compiled = gettextParser.mo.compile(json);
+      expect(compiled).to.deep.equal(mo);
     });
+  });
 
-    describe('Latin-13', function() {
-        it('should compile', function() {
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-mo.json', 'utf-8'));
-            var mo = fs.readFileSync(__dirname + '/fixtures/latin13.mo');
-            var compiled = gettextParser.mo.compile(json);
-            expect(compiled).to.deep.equal(mo);
-        });
+  describe('Latin-13', function () {
+    it('should compile', function () {
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/latin13-mo.json'), 'utf-8'));
+      var mo = fs.readFileSync(path.join(__dirname, 'fixtures/latin13.mo'));
+      var compiled = gettextParser.mo.compile(json);
+      expect(compiled).to.deep.equal(mo);
     });
-});
\ No newline at end of file
+  });
+});
diff --git a/test/mo-parser-test.js b/test/mo-parser-test.js
index a8d9895..ac0f42d 100644
--- a/test/mo-parser-test.js
+++ b/test/mo-parser-test.js
@@ -3,27 +3,27 @@
 var chai = require('chai');
 var gettextParser = require('..');
 var fs = require('fs');
+var path = require('path');
 
 var expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('MO Parser', function() {
-
-    describe('UTF-8', function() {
-        it('should parse', function() {
-            var mo = fs.readFileSync(__dirname + '/fixtures/utf8.mo');
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-mo.json', 'utf-8'));
-            var parsed = gettextParser.mo.parse(mo);
-            expect(parsed).to.deep.equal(json);
-        });
+describe('MO Parser', function () {
+  describe('UTF-8', function () {
+    it('should parse', function () {
+      var mo = fs.readFileSync(path.join(__dirname, 'fixtures/utf8.mo'));
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/utf8-mo.json'), 'utf-8'));
+      var parsed = gettextParser.mo.parse(mo);
+      expect(parsed).to.deep.equal(json);
     });
+  });
 
-    describe('Latin-13', function() {
-        it('should parse', function() {
-            var mo = fs.readFileSync(__dirname + '/fixtures/latin13.mo');
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-mo.json', 'utf-8'));
-            var parsed = gettextParser.mo.parse(mo);
-            expect(parsed).to.deep.equal(json);
-        });
+  describe('Latin-13', function () {
+    it('should parse', function () {
+      var mo = fs.readFileSync(path.join(__dirname, 'fixtures/latin13.mo'));
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/latin13-mo.json'), 'utf-8'));
+      var parsed = gettextParser.mo.parse(mo);
+      expect(parsed).to.deep.equal(json);
     });
-});
\ No newline at end of file
+  });
+});
diff --git a/test/po-compiler-test.js b/test/po-compiler-test.js
index 8b461e4..f37b4e4 100644
--- a/test/po-compiler-test.js
+++ b/test/po-compiler-test.js
@@ -3,37 +3,37 @@
 var chai = require('chai');
 var gettextParser = require('..');
 var fs = require('fs');
+var path = require('path');
 
 var expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('PO Compiler', function() {
+describe('PO Compiler', function () {
+  describe('UTF-8', function () {
+    it('should compile', function () {
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf-8'));
+      var po = fs.readFileSync(path.join(__dirname, 'fixtures/utf8.po'));
 
-    describe('UTF-8', function() {
-        it('should compile', function() {
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8'));
-            var po = fs.readFileSync(__dirname + '/fixtures/utf8.po');
-
-            var compiled = gettextParser.po.compile(json);
-            expect(compiled).to.deep.equal(po);
-        });
+      var compiled = gettextParser.po.compile(json);
+      expect(compiled).to.deep.equal(po);
     });
+  });
 
-    describe('Latin-13', function() {
-        it('should compile', function() {
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-po.json', 'utf-8'));
-            var po = fs.readFileSync(__dirname + '/fixtures/latin13.po');
-            var compiled = gettextParser.po.compile(json);
-            expect(compiled).to.deep.equal(po);
-        });
+  describe('Latin-13', function () {
+    it('should compile', function () {
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/latin13-po.json'), 'utf-8'));
+      var po = fs.readFileSync(path.join(__dirname, 'fixtures/latin13.po'));
+      var compiled = gettextParser.po.compile(json);
+      expect(compiled).to.deep.equal(po);
     });
+  });
 
-    describe('Plurals', function() {
-        it('should compile correct plurals in POT files', function() {
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/plural-pot.json', 'utf-8'));
-            var pot = fs.readFileSync(__dirname + '/fixtures/plural.pot');
-            var compiled = gettextParser.po.compile(json);
-            expect(compiled).to.deep.equal(pot);
-        });
+  describe('Plurals', function () {
+    it('should compile correct plurals in POT files', function () {
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/plural-pot.json'), 'utf-8'));
+      var pot = fs.readFileSync(path.join(__dirname, 'fixtures/plural.pot'));
+      var compiled = gettextParser.po.compile(json);
+      expect(compiled).to.deep.equal(pot);
     });
+  });
 });
diff --git a/test/po-parser-test.js b/test/po-parser-test.js
index 8e908fe..78d067d 100644
--- a/test/po-parser-test.js
+++ b/test/po-parser-test.js
@@ -3,59 +3,57 @@
 var chai = require('chai');
 var gettextParser = require('..');
 var fs = require('fs');
+var path = require('path');
 
 var expect = chai.expect;
 chai.config.includeStack = true;
 
-describe('PO Parser', function() {
-
-    describe('UTF-8', function() {
-        it('should parse', function() {
-            var po = fs.readFileSync(__dirname + '/fixtures/utf8.po');
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8'));
-            var parsed = gettextParser.po.parse(po);
-            expect(parsed).to.deep.equal(json);
-        });
+describe('PO Parser', function () {
+  describe('UTF-8', function () {
+    it('should parse', function () {
+      var po = fs.readFileSync(path.join(__dirname, 'fixtures/utf8.po'));
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf-8'));
+      var parsed = gettextParser.po.parse(po);
+      expect(parsed).to.deep.equal(json);
     });
-
-    describe('UTF-8 as a string', function() {
-        it('should parse', function() {
-            var po = fs.readFileSync(__dirname + '/fixtures/utf8.po', 'utf-8');
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8'));
-            var parsed = gettextParser.po.parse(po);
-            expect(parsed).to.deep.equal(json);
-        });
+  });
+
+  describe('UTF-8 as a string', function () {
+    it('should parse', function () {
+      var po = fs.readFileSync(path.join(__dirname, 'fixtures/utf8.po'), 'utf-8');
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf-8'));
+      var parsed = gettextParser.po.parse(po);
+      expect(parsed).to.deep.equal(json);
     });
-
-    describe('Stream input', function() {
-        it('should parse', function(done) {
-            var po = fs.createReadStream(__dirname + '/fixtures/utf8.po', {
-                highWaterMark: 1 // ensure that any utf-8 sequences will be broken when streaming
-            });
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/utf8-po.json', 'utf-8'));
-
-            var parsed;
-            var stream = po.pipe(gettextParser.po.createParseStream({
-                initialTreshold: 800 // home many bytes to cache for parsing the header
-            }));
-            stream.on('data', function(data) {
-                parsed = data;
-            });
-            stream.on('end', function() {
-                expect(parsed).to.deep.equal(json);
-                done();
-            });
-
-        });
+  });
+
+  describe('Stream input', function () {
+    it('should parse', function (done) {
+      var po = fs.createReadStream(path.join(__dirname, 'fixtures/utf8.po'), {
+        highWaterMark: 1 // ensure that any utf-8 sequences will be broken when streaming
+      });
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/utf8-po.json'), 'utf-8'));
+
+      var parsed;
+      var stream = po.pipe(gettextParser.po.createParseStream({
+        initialTreshold: 800 // home many bytes to cache for parsing the header
+      }));
+      stream.on('data', function (data) {
+        parsed = data;
+      });
+      stream.on('end', function () {
+        expect(parsed).to.deep.equal(json);
+        done();
+      });
     });
-
-    describe('Latin-13', function() {
-        it('should parse', function() {
-            var po = fs.readFileSync(__dirname + '/fixtures/latin13.po');
-            var json = JSON.parse(fs.readFileSync(__dirname + '/fixtures/latin13-po.json', 'utf-8'));
-            var parsed = gettextParser.po.parse(po);
-            expect(parsed).to.deep.equal(json);
-        });
+  });
+
+  describe('Latin-13', function () {
+    it('should parse', function () {
+      var po = fs.readFileSync(path.join(__dirname, 'fixtures/latin13.po'));
+      var json = JSON.parse(fs.readFileSync(path.join(__dirname, 'fixtures/latin13-po.json'), 'utf-8'));
+      var parsed = gettextParser.po.parse(po);
+      expect(parsed).to.deep.equal(json);
     });
-
-});
\ No newline at end of file
+  });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-gettext-parser.git



More information about the Pkg-javascript-commits mailing list