Opened 10 years ago

Closed 10 years ago

#23788 closed Cleanup/optimization (fixed)

Stop templatizing js files for gettext >= 0.18.3

Reported by: Claude Paroz Owned by: Claude Paroz
Component: Internationalization Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Gettext 0.18.3 (July 2013) added support for parsing JavaScript files with xgettext. This should allow us to stop using jslex.prepare_js_for_gettext when an appropriate version is available.

http://lists.gnu.org/archive/html/info-gnu/2013-07/msg00001.html

Change History (11)

comment:1 by Aymeric Augustin, 10 years ago

Triage Stage: UnreviewedAccepted

Good idea. If we take advantage of this feature before it makes it into a stable release of mainstream Linux distros, we should test for its availability (probably with a simple version check) and fallback to the current behavior.

comment:3 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 5ec367ccdd2ff70270b1f578821c817785d7aecf:

Fixed #23788 -- Used new JavaScript support in recent gettext

JavaScript string extraction support has been added in gettext
0.18.3.
Thanks Aymeric Augustin for the review.

comment:4 by Tim Graham, 10 years ago

Has patch: unset
Resolution: fixed
Severity: NormalRelease blocker
Status: closednew

Some tests are failing on Windows after this change.

======================================================================
ERROR: test_media_static_dirs_ignored (i18n.test_extraction.JavascriptExtractorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\users\tim\code\django\django\test\utils.py", line 275, in inner
    return test_func(*args, **kwargs)
  File "c:\Users\Tim\code\django\tests\i18n\test_extraction.py", line 376, in test_media_static_dirs_ignored
    _, po_contents = self._run_makemessages(domain='djangojs')
  File "c:\Users\Tim\code\django\tests\i18n\test_extraction.py", line 62, in _run_makemessages
    stdout=out, **options)
  File "c:\users\tim\code\django\django\core\management\__init__.py", line 120,
in call_command
    return command.execute(*args, **defaults)
  File "c:\users\tim\code\django\django\core\management\base.py", line 442, in execute
    output = self.handle(*args, **options)
  File "c:\users\tim\code\django\django\core\management\commands\makemessages.py
", line 298, in handle
    potfiles = self.build_potfiles()
  File "c:\users\tim\code\django\django\core\management\commands\makemessages.py
", line 327, in build_potfiles
    f.process(self, self.domain)
  File "c:\users\tim\code\django\django\core\management\commands\makemessages.py
", line 68, in process
    is_templatized = command.gettext_version < (0, 18, 3)
  File "c:\users\tim\code\django\django\utils\functional.py", line 60, in __get_
    res = instance.__dict__[self.name] = self.func(instance)
  File "c:\users\tim\code\django\django\core\management\commands\makemessages.py
", line 317, in gettext_version
    raise CommandError("Unable to get gettext version. Is it installed?")
CommandError: Unable to get gettext version. Is it installed?

comment:5 by Claude Paroz, 10 years ago

I'm sorry, but I don't have access to any Windows system, so it will have to be handled by someone else :-/

comment:6 by Tim Graham, 10 years ago

Keywords: windows-test-failure added

comment:7 by Tim Graham, 10 years ago

Has patch: set
Keywords: windows-test-failure removed

It seems this is not actually specific to Windows, but a problem if xgettext --version doesn't have 3 digits (something like 0.17). Care to improve the regex at all? Not sure if we should try to mock out popen_wrapper to add a test for it.

diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index ba8de52..932bc08 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -310,9 +310,9 @@ class Command(BaseCommand):
     @cached_property
     def gettext_version(self):
         out, err, status = popen_wrapper(['xgettext', '--version'])
-        m = re.search(r'(\d)\.(\d+)\.(\d+)', out)
+        m = re.search(r'(\d)\.(\d+)\.?(\d+)?', out)
         if m:
-            return tuple(int(d) for d in m.groups())
+            return tuple(int(d) for d in m.groups() if d is not None)
         else:
             raise CommandError("Unable to get gettext version. Is it installed?")

comment:8 by Claude Paroz, 10 years ago

Owner: changed from nobody to Claude Paroz
Status: newassigned

comment:10 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:11 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 9bcd4d812ca698fd3a2de8c52cae8e63c261e628:

Fixed #23788 (2) -- Improved gettext version checker

Thanks Tim Graham for the report and initial patch.

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