diff -r bd551af8275b django/core/management/commands/makemessages.py
a
|
b
|
|
76 | 76 | message = "usage: make-messages.py -l <language>\n or: make-messages.py -a\n" |
77 | 77 | raise CommandError(message) |
78 | 78 | |
79 | | # xgettext versions prior to 0.15 assumed Python source files were encoded |
80 | | # in iso-8859-1, and produce utf-8 output. In the case where xgettext is |
81 | | # given utf-8 input (required for Django files with non-ASCII characters), |
82 | | # this results in a utf-8 re-encoding of the original utf-8 that needs to be |
83 | | # undone to restore the original utf-8. So we check the xgettext version |
84 | | # here once and set a flag to remember if a utf-8 decoding needs to be done |
85 | | # on xgettext's output for Python files. We default to assuming this isn't |
86 | | # necessary if we run into any trouble determining the version. |
87 | | xgettext_reencodes_utf8 = False |
| 79 | # We require gettext version 0.15 or newer. |
88 | 80 | (stdin, stdout, stderr) = os.popen3('xgettext --version', 't') |
89 | 81 | match = re.search(r'(?P<major>\d+)\.(?P<minor>\d+)', stdout.read()) |
90 | 82 | if match: |
91 | 83 | xversion = (int(match.group('major')), int(match.group('minor'))) |
92 | 84 | if xversion < (0, 15): |
93 | | xgettext_reencodes_utf8 = True |
94 | | |
| 85 | raise CommandError("Django internationalization requires GNU gettext 0.15 or newer. You are using version %s, please upgrade your gettext toolset." % match.group()) |
| 86 | |
95 | 87 | languages = [] |
96 | 88 | if locale is not None: |
97 | 89 | languages.append(locale) |
98 | 90 | elif all: |
99 | | locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir)) |
| 91 | locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir)) |
100 | 92 | languages = [os.path.basename(l) for l in locale_dirs] |
101 | | |
| 93 | |
102 | 94 | for locale in languages: |
103 | 95 | if verbosity > 0: |
104 | 96 | print "processing language", locale |
… |
… |
|
162 | 154 | if errors: |
163 | 155 | raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors)) |
164 | 156 | |
165 | | if xgettext_reencodes_utf8: |
166 | | msgs = msgs.decode('utf-8').encode('iso-8859-1') |
167 | | |
168 | 157 | if thefile != file: |
169 | 158 | old = '#: '+os.path.join(dirpath, thefile)[2:] |
170 | 159 | new = '#: '+os.path.join(dirpath, file)[2:] |
diff -r bd551af8275b docs/topics/i18n.txt
a
|
b
|
|
512 | 512 | The old tool ``bin/make-messages.py`` has been moved to the command |
513 | 513 | ``django-admin.py makemessages`` to provide consistency throughout Django. |
514 | 514 | |
| 515 | .. admonition:: Gettext utilities |
| 516 | |
| 517 | The ``makemessages`` command (and ``compilemessages`` discussed later) use |
| 518 | commands from the GNU gettext toolset: ``xgetetxt``, ``msgfmt``, |
| 519 | ``msgmerge`` and ``msguniq``. |
| 520 | |
| 521 | .. versionchanged:: 1.2 |
| 522 | |
| 523 | The minimum version of the ``gettext`` utilities supported is 0.15. |
| 524 | |
515 | 525 | To create or update a message file, run this command:: |
516 | 526 | |
517 | 527 | django-admin.py makemessages -l de |