i18next/i18next-gettext-converter — pull request #15 by redking (2014-10-09 15:18:51+00:00)
Title: Add ability to optionally filter PO translations

Hey,

This PR addresses the case where we wish to filter some PO translations from the exported JSON. For example, front- and back-end translations may all reside in the same PO file; as we don't wish to serve all these for use on the client-side, we exclude all back-end translations.

The changes here allow the path to a filtering function to be optionally passed on the command line. This function takes the gettext object and a callback as arguments, performs its filtering operation and then invokes the callback with the translation table.

I have included an example filter in `testfiles/filter.js`. It inspects the 'code' comment for each translation, excluding those that are only used in backend templates.

You would invoke the i18next-conv command as below

```shell
i18next-conv -l en -s testfiles/utf8_unfiltered.po -t ./output/utf8_filtered.json -f ./testfiles/filter.js
```

The outputted JSON will only contain those translations with a code comment that contains the `/frontend/` string.

This is for a particular use-case, but I think it might be interested for the general user. I intend to write some unit tests for the change, which I will include in the PR, but I'd be interested in your feedback in the meantime.

Thanks!