Opened 14 years ago

Closed 13 years ago

#14045 closed Bug (fixed)

makemessage miss some gettext in javascript

Reported by: Shao Hao Owned by: Ned Batchelder
Component: Internationalization Version: 1.2
Severity: Normal Keywords: xgettext
Cc: ramusus@…, ned@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Here is a simple javascript code for testing:

function mfunc() {
    var val = 0;
    return val ? 1 : 0;
}
gettext('okkkk');
print mysub();

save it as 'result.pl'
Now run:

xgettext -d out -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "result.pl"

Ouput nothing

Change History (13)

comment:1 by Shao Hao, 14 years ago

If i change:

return val ? 1 : 0;

to {{{
return $val ? 1 : 0;
}}}

xgettext works.

comment:2 by Matthias Kestenholz, 14 years ago

Resolution: worksforme
Status: newclosed

I cannot reproduce this failure:

$ xgettext -d out -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "result.pl"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-10-05 12:32+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: result.pl:5
msgid "okkkk"
msgstr ""

Even if this would happen this would not be a Django but a gettext bug.

comment:3 by ramusus, 14 years ago

Cc: ramusus@… added

The same occured to me. After my last Ubuntu update from 9.4 to 10.10 version, makemessages command for javascripts starts to process my files incompletely. I investigate this problem deeper and come to conclusion the main reason is gettext package. It was the version 0.18.1.1-1ubuntu2. After downgrading gettext to 0.17-8ubuntu3 the problem disappeared.

I don't know is it a normal behavior of gettext or bug. I understand gettext doesn't support straight Javasript language support, but nevertheless setting "-L Perl" worried me. Is there no any other parsers for javascripts?

comment:4 by ramusus, 14 years ago

Resolution: worksforme
Status: closedreopened

I reopen ticket because. this problem may occur on some system distributions, I noticed above the reason and specification. Also I understand the problem is not inside Django. The problem inside gettext package or the way how Django use it.

comment:5 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

Accepting on the basis someone has reproduced the issue on Ubuntu 10.10. Open to any suggestions on whether this is a local configuration issue, an Ubuntu packaging stuff up, or a Django usage problem.

comment:6 by Jannis Leidel, 14 years ago

Yeah, I was able to reproduce this myself, and I first thought it would be able to be fixed by changing from using "Perl" to "Python". Guess we need to limit the use of gettext to 0.17 for now.

comment:7 by Claude Paroz, 14 years ago

And as jezdez told us on IRC, the middle-term solution would be to use a real Javascript parser (not available in xgettext) to extract strings from js files (like the one in Babel: http://svn.edgewall.org/repos/babel/trunk/babel/messages/jslexer.py).

in reply to:  7 comment:8 by Łukasz Rekucki, 14 years ago

Replying to claudep:

And as jezdez told us on IRC, the middle-term solution would be to use a real Javascript parser (not available in xgettext) to extract strings from js files (like the one in Babel: http://svn.edgewall.org/repos/babel/trunk/babel/messages/jslexer.py).

+Inf on using a real lexer/parser. See #15495 for another weird bug.

comment:9 by Ned Batchelder, 14 years ago

Owner: changed from nobody to Ned Batchelder
Severity: Normal
Status: reopenednew
Type: Uncategorized

comment:10 by Ned Batchelder, 14 years ago

Type: UncategorizedBug

comment:11 by Ned Batchelder, 14 years ago

Cc: ned@… added
Has patch: set

See the patches on #7704 for a fix.

comment:12 by Jacob, 14 years ago

Easy pickings: unset

See also #15832 (which covers switching to Babel).

comment:13 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

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