#4695 closed (fixed)
xgettext skips some translation strings in javascript files
Reported by: | 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 )
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)
Change History (11)
comment:1 by , 17 years ago
comment:3 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 16 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 , 15 years ago
Has patch: | set |
---|---|
Version: | 0.96 → SVN |
This one-line fix against current trunk (11227) would solve the problem.
-
core/management/commands/makemessages.py
17 17 # still sensible for us to use it, since subprocess didn't exist in 2.3. 18 18 warnings.filterwarnings('ignore', category=DeprecationWarning, message=r'os\.popen3') 19 19 20 pythonize_re = re.compile(r' \n\s*//')20 pythonize_re = re.compile(r'(?:^|\n)\s*//') 21 21 22 22 def handle_extensions(extensions=('html',)): 23 23 """
comment:6 by , 15 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 , 15 years ago
milestone: | → 1.2 |
---|---|
Owner: | changed from | to
comment:8 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Sorry for the broken new lines.