Opened 13 years ago

Closed 13 years ago

#15495 closed Bug (fixed)

makemessages excludes all strings from Javascript after a comment

Reported by: Łukasz Rekucki Owned by: Ned Batchelder
Component: Internationalization Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

A sample code (shortened as much as possible, the original comment was something like "get/set doesn't ...", so it's not synthetic):

/* / ' */ gettext("TEXT");

xgettext doesn't find any translations after the shown comment. Removing either / or ' fixes the problem. This is a bit related to #4695.

Attachments (1)

ticket15495.diff (7.2 KB ) - added by Łukasz Rekucki 13 years ago.
A bit naive patch with tests.

Download all attachments as: .zip

Change History (10)

comment:1 by Łukasz Rekucki, 13 years ago

Summary: {{{makemessages}}} excludes all strings from Javascript after a commentmakemessages excludes all strings from Javascript after a comment

comment:2 by Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted

by Łukasz Rekucki, 13 years ago

Attachment: ticket15495.diff added

A bit naive patch with tests.

comment:3 by Łukasz Rekucki, 13 years ago

Has patch: set

The patch fixes this particular problem (and some similar to it), but it's not too hard to construct a valid JavaScript that gets omited or improperly mangled by regexps. Just a few examples:

gettext("String"); // This comment won't be caught by pythonize_re and it contains "'" which is a string start in Perl
/* 
 * This one will be removed by the patch
 */
gettext("/* but this one will be too */ 'cause there is no way of telling...");
f(/* ... if it's different from this one */);

The only real fix is having a JavaScript lexer and (probaly simplified) parser instead of a bunch of hacky regexps. No time to do it right now, so maybe someone else wants to do it.

comment:4 by Łukasz Rekucki, 13 years ago

Severity: Normal
Type: Bug

comment:5 by Ned Batchelder, 13 years ago

Owner: changed from nobody to Ned Batchelder
Status: newassigned

comment:6 by Julien Phalip, 13 years ago

Patch needs improvement: set

Patch needs improvement as per Łukasz's comment above.

comment:7 by Ned Batchelder, 13 years ago

Yes, I'm working on a real patch to include a Javascript lexer.

comment:8 by Ned Batchelder, 13 years ago

Patch attached to #7704 fixes this problem.

comment:9 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: assignedclosed

In [16333]:

Fixed #7704, #14045 and #15495 -- Introduce a lexer for Javascript to fix multiple problems of the translation of Javascript files with xgettext. Many thanks to Ned Batchelder for his contribution of the JsLex library.

Note: See TracTickets for help on using tickets.
Back to Top