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

File 12673-require-getetx-015.diff, 3.2 KB (added by ramiro, 6 years ago)
  • django/core/management/commands/makemessages.py

    diff -r bd551af8275b django/core/management/commands/makemessages.py
    a b  
    7676            message = "usage: make-messages.py -l <language>\n   or: make-messages.py -a\n"
    7777        raise CommandError(message)
    7878
    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.
    8880    (stdin, stdout, stderr) = os.popen3('xgettext --version', 't')
    8981    match = re.search(r'(?P<major>\d+)\.(?P<minor>\d+)', stdout.read())
    9082    if match:
    9183        xversion = (int(match.group('major')), int(match.group('minor')))
    9284        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
    9587    languages = []
    9688    if locale is not None:
    9789        languages.append(locale)
    9890    elif all:
    99         locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir)) 
     91        locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
    10092        languages = [os.path.basename(l) for l in locale_dirs]
    101    
     93
    10294    for locale in languages:
    10395        if verbosity > 0:
    10496            print "processing language", locale
     
    162154                if errors:
    163155                    raise CommandError("errors happened while running xgettext on %s\n%s" % (file, errors))
    164156
    165                 if xgettext_reencodes_utf8:
    166                     msgs = msgs.decode('utf-8').encode('iso-8859-1')
    167 
    168157                if thefile != file:
    169158                    old = '#: '+os.path.join(dirpath, thefile)[2:]
    170159                    new = '#: '+os.path.join(dirpath, file)[2:]
  • docs/topics/i18n.txt

    diff -r bd551af8275b docs/topics/i18n.txt
    a b  
    512512    The old tool ``bin/make-messages.py`` has been moved to the command
    513513    ``django-admin.py makemessages`` to provide consistency throughout Django.
    514514
     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
    515525To create or update a message file, run this command::
    516526
    517527    django-admin.py makemessages -l de
Back to Top