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 , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 10 years ago
Has patch: | unset |
---|---|
Resolution: | fixed |
Severity: | Normal → Release blocker |
Status: | closed → new |
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 , 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 , 10 years ago
Keywords: | windows-test-failure added |
---|
comment:7 by , 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 , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:10 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:11 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.