Opened 17 years ago

Closed 14 years ago

Last modified 12 years ago

#4695 closed (fixed)

xgettext skips some translation strings in javascript files

Reported by: voy@… Owned by: Ramiro Morales
Component: Internationalization Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Malcolm Tredinnick)

For a simple Javascript source file like this:

// '
gettext("foo");
// '
gettext("bar");

results of make-messages.py run will exclude the "foo" string. Apparently this is related to the presence of apostrophes in the preceding comment. I am using gettext 0.14.4 under win32. I suspect this might be some quirk in relation to xgettext being called with Perl in the language parameter.

Attachments (1)

4695-javascript-makemessages-fix.diff (3.1 KB ) - added by Ramiro Morales 14 years ago.
Fix by seveas plus tests

Download all attachments as: .zip

Change History (11)

comment:1 by voy@…, 17 years ago

Sorry for the broken new lines.

// '
gettext("foo");
// '
gettext("bar");

comment:2 by Malcolm Tredinnick, 17 years ago

Description: modified (diff)

Fixed description.

comment:3 by Simon G <dev@…>, 16 years ago

Triage Stage: UnreviewedAccepted

comment:4 by dc, 15 years ago

For this javascript makemessages runs pythonize_re and produces temporary .py file:

// '
gettext("foo");
# '
gettext("bar");

then calls xgettext to process it as perl source.

If we will ignore nonsense conversions, the problem is in pythonize_re which is defined as

r'\n\s*//'

and will not match at the beginning of the file.

But with all that really dirty magic the problem can be in another place.

comment:5 by Dennis Kaarsemaker, 15 years ago

Has patch: set
Version: 0.96SVN

This one-line fix against current trunk (11227) would solve the problem.

  • core/management/commands/makemessages.py

     
    1717# still sensible for us to use it, since subprocess didn't exist in 2.3.
    1818warnings.filterwarnings('ignore', category=DeprecationWarning, message=r'os\.popen3')
    1919
    20 pythonize_re = re.compile(r'\n\s*//')
     20pythonize_re = re.compile(r'(?:^|\n)\s*//')
    2121
    2222def handle_extensions(extensions=('html',)):
    2323    """

by Ramiro Morales, 14 years ago

Fix by seveas plus tests

comment:6 by Ramiro Morales, 14 years ago

I've attached a patch that contains the simple regular expression fix described by seveas plus the beginnings of regression tests for the translatable literal extraction functionality. Hopefully we will be able to expand them with more Javascript extraction corner cases and to add template extraction cases.

comment:7 by Ramiro Morales, 14 years ago

milestone: 1.2
Owner: changed from nobody to Ramiro Morales

comment:8 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

(In [12441]) Fixed #4695 - Worked around a problem of xgettext ignoring some translation strings in JavaScript files. Thanks, Ramiro Morales.

comment:9 by Jannis Leidel, 14 years ago

(In [12451]) [1.1.X] Fixed #4695 - Worked around a problem of xgettext ignoring some translation strings in JavaScript files. Thanks, Ramiro Morales.

Backport of r12441.

comment:10 by Jacob, 12 years ago

milestone: 1.2

Milestone 1.2 deleted

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