mikeedwards/po2json — pull request #15 by ragulka (2013-11-08 10:41:31+00:00)
Title: Major library rewrite. Fixes current issues and conforms better with node scripting styles.

This is a huge rewrite to this library. The rewrite is so thorough that I didn't bother separating it into smaller commits. Instead, I will try to explain the changes and the rationale behind them here.

If this get's merged, it should fix issues #13 and #14.

**Parsing**
Instead of rolling our own PO parsing, I switched to using [gettext-parser](https://github.com/andris9/gettext-parser), which is pretty solid and covered with more thorough tests. gettext-parser parses the PO file and provides it's own JSON output specific to itself. Here's where we need to convert it to a classical gettext/Jed compatible JSON and that's actually the only "hard" job this module now has to take care of.

Why switch to gettext-parser? Because it is well tested and doesn't have any of the issues that `po2json` self parser has at the moment. I think it makes a lot of sense to use solid, tested modules whenever possible.

**Code style**
I changed a lot of the code style to better follow the best practices in the Node community. For example, string and method names should always use camelCase, not underscores. I removed jshint grunt task simply ebeause it didn't seem to provide any real value.
Conforming to node standards also lead me to rename the methods.

**Breaking changes**
I have renamed the methods in a backwards-incompatible way:
* `po2json.parse_po` has been replaced with `po2json.parse`
* `po2json.parse` has been replaced with `po2json.parseFile`
* `po2json.parseSync` has been replaced with `po2json.parseFileSync`

I believe this way the method names are not ambiguous anymore and follow a certain logic used in node and it's modules.

**Tests**
I have completely rewritten the tests and fixtures. First, I removed the basic test, because it didn't really provide any value. Second, I switched to a polish po file simply because polish has 3 plural forms which places higher requirements for the parser.

I also added tests for escaped quotes (`This is a \"message\" in quotes`) and fuzzy translations.

**New features**
There's actually only 1 new feature: option to skip or include fuzzy translations (fuzzy translations are translations which are marked as fuzzy (uncertain, perhaps not complete) by the translator).

**Other stuff**
I took the liberty to bump the version number to 0.2.0, because this is a major rewrite and should not be considered backwards compatible. I also updated the README and History files with the latest information, changes and warning about braking changes. README has also now been updated with full documentation.
The actual release and version tagging) should, of course, be done my the maintainer.

**Final thoughts**
I realize that this might be a lot to take in with a single pull request, but I didn't want to create another po2json module simply because I can. I believe it is best to try to contribute to existing projects as this helps the node community far better. In no way am I trying to diss the work of previous authors and contributors - and I hope you do not see it this way.

I hope that you will see that the end result is better, more reliable and helps us all.