Opened 6 years ago

Closed 5 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: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

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 6 years ago.
A bit naive patch with tests.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by Łukasz Rekucki

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Summary: {{{makemessages}}} excludes all strings from Javascript after a commentmakemessages excludes all strings from Javascript after a comment

comment:2 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

Changed 6 years ago by Łukasz Rekucki

Attachment: ticket15495.diff added

A bit naive patch with tests.

comment:3 Changed 6 years ago by Łukasz Rekucki

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 Changed 6 years ago by Łukasz Rekucki

Severity: Normal
Type: Bug

comment:5 Changed 5 years ago by Ned Batchelder

Owner: changed from nobody to Ned Batchelder
Status: newassigned

comment:6 Changed 5 years ago by Julien Phalip

Patch needs improvement: set

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

comment:7 Changed 5 years ago by Ned Batchelder

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

comment:8 Changed 5 years ago by Ned Batchelder

Patch attached to #7704 fixes this problem.

comment:9 Changed 5 years ago by Jannis Leidel

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