Mindflash / grunt-jsxgettext

2 stars 11 forks source link

Support all jsxgettext options #1

Open mphasize opened 10 years ago

mphasize commented 10 years ago

Hi,

would it be possible to support all of the command line options for jsxgettext? I'm especially looking for the --join-existing setting. That way, we could generate the .po files directly with the grunt task.

Cheers! Marcus

https://github.com/zaach/jsxgettext

Options:

-o FILE, --output FILE     write output to specified file
-p DIR, --output-dir DIR   output files will be placed in directory DIR
-v, --version              print version and exit
-k WORD, --keyword WORD    additional keyword to be looked for
-j, --join-existing        join messages with existing file
-L NAME, --language NAME   use the specified language (javascript, ejs, jinja, handlebars, jade)
-s, --sanity               sanity check during the extraction
maxnachlinger commented 10 years ago

That should be simple to add, so kick me pull request if you have a minute. Otherwise, if you don't mind waiting a week or so, I'll throw that in.

mphasize commented 10 years ago

Hi Max, I went through the code and saw that it actually is already possible to pass the options around.

            options: {
            keyword: [ 'gettext', '__' ], // multiple keywords
            "join-existing": true
        }

This block in the config of the grunt tasks passes the "join-existing" over to jsxgettext. There is however another issue: With the option join-existing set, jsxgettext expects the options "output-dir" and "output" (i.e. file) to be given and fails otherwise. (See https://github.com/zaach/jsxgettext/blob/master/lib/jsxgettext.js Line:83) The grunt task meanwhile is configured with files and dest settings and technically dest is the same as output-dir and output combined, but it's not fed into the jsxgettext options.

The easy workaround is to set the output again in the options block and a possible fix would be to translate the dest setting to output-dir and output.

Cheers! M