zaach / jsxgettext

Extract gettext calls from JavaScript, EJS, and other template formats.
Mozilla Public License 2.0
105 stars 56 forks source link

Extracting comments #58

Closed mphasize closed 10 years ago

mphasize commented 10 years ago

Although mentioned in the README, the extraction of translator comments from the source code is not working. It looks like the function findComments is never even called.

@plemarquand seems to have figured out how to do this including proper tests. https://github.com/plemarquand/jsxgettext/commit/6c3d0be2f8e44137b390e14ad6e9dbb5353d2f44

Support for comments should also follow the standard gettext format for translator comments, i.e. comments beginning with a triple slash /// (at least in plain JavaScript files).

Is there any chance for this to get merged into the main distribution of jsxgettext?

BYK commented 10 years ago

Interesting that we don't have any tests for this behavior. I'll give it a deeper look and update this ticket. I can't merge a commit if someone does not open a pull request for it but I can most certainly try to fix the issue.

Thanks for reporting!

BYK commented 10 years ago

So it turns out this is due to a simple mistake. We look at node.line and assume it is an integer but it is actually an object: {line: 2, column: 0}. Fixing that fixes the issue so I'll just do that and add some tests. For /// style comments I need to defer to @zaach since he is the one who started using the L10n syntax in the first place and I don't know how that decision was made. Anyways, that will be a separate issue.

mphasize commented 10 years ago

Wow, thanks for looking into this so quickly!

mphasize commented 10 years ago

One more thing though:

The comments that are included in the .po / .pot files should be prefixed with #. instead of just # since they are extracted comments for the translator (and not comments made by the translator). See Gettext PO file format.