Code

Ticket #12673: 12673-require-getetx-015.diff

File 12673-require-getetx-015.diff, 3.2 KB (added by ramiro, 4 years ago)
Line 
1diff -r bd551af8275b django/core/management/commands/makemessages.py
2--- a/django/core/management/commands/makemessages.py   Sat Jan 23 01:32:34 2010 -0300
3+++ b/django/core/management/commands/makemessages.py   Sat Jan 23 11:52:22 2010 -0300
4@@ -76,29 +76,21 @@
5             message = "usage: make-messages.py -l <language>\n   or: make-messages.py -a\n"
6         raise CommandError(message)
7 
8-    # xgettext versions prior to 0.15 assumed Python source files were encoded
9-    # in iso-8859-1, and produce utf-8 output.  In the case where xgettext is
10-    # given utf-8 input (required for Django files with non-ASCII characters),
11-    # this results in a utf-8 re-encoding of the original utf-8 that needs to be
12-    # undone to restore the original utf-8.  So we check the xgettext version
13-    # here once and set a flag to remember if a utf-8 decoding needs to be done
14-    # on xgettext's output for Python files.  We default to assuming this isn't
15-    # necessary if we run into any trouble determining the version.
16-    xgettext_reencodes_utf8 = False
17+    # We require gettext version 0.15 or newer.
18     (stdin, stdout, stderr) = os.popen3('xgettext --version', 't')
19     match = re.search(r'(?P<major>\d+)\.(?P<minor>\d+)', stdout.read())
20     if match:
21         xversion = (int(match.group('major')), int(match.group('minor')))
22         if xversion < (0, 15):
23-            xgettext_reencodes_utf8 = True
24-
25+            raise CommandError("Django internationalization requires GNU gettext 0.15 or newer. You are using version %s, please upgrade your gettext toolset." % match.group())
26+
27     languages = []
28     if locale is not None:
29         languages.append(locale)
30     elif all:
31-        locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
32+        locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
33         languages = [os.path.basename(l) for l in locale_dirs]
34-   
35+
36     for locale in languages:
37         if verbosity > 0:
38             print "processing language", locale
39@@ -162,9 +154,6 @@
40                 if errors:
41                     raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors))
42 
43-                if xgettext_reencodes_utf8:
44-                    msgs = msgs.decode('utf-8').encode('iso-8859-1')
45-
46                 if thefile != file:
47                     old = '#: '+os.path.join(dirpath, thefile)[2:]
48                     new = '#: '+os.path.join(dirpath, file)[2:]
49diff -r bd551af8275b docs/topics/i18n.txt
50--- a/docs/topics/i18n.txt      Sat Jan 23 01:32:34 2010 -0300
51+++ b/docs/topics/i18n.txt      Sat Jan 23 11:52:22 2010 -0300
52@@ -512,6 +512,16 @@
53     The old tool ``bin/make-messages.py`` has been moved to the command
54     ``django-admin.py makemessages`` to provide consistency throughout Django.
55 
56+.. admonition:: Gettext utilities
57+
58+    The ``makemessages`` command (and ``compilemessages`` discussed later) use
59+    commands from the GNU gettext toolset: ``xgetetxt``, ``msgfmt``,
60+    ``msgmerge`` and ``msguniq``.
61+
62+    .. versionchanged:: 1.2
63+
64+    The minimum version of the ``gettext`` utilities supported is 0.15.
65+
66 To create or update a message file, run this command::
67 
68     django-admin.py makemessages -l de