Ticket #6476: nowrap.patch

File nowrap.patch, 3.6 KB (added by pytechd <pytechd@…>, 16 years ago)
  • bin/make-messages.py

     
    2929        print "you want to enable i18n for your project or application."
    3030        sys.exit(1)
    3131
    32     (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va')
     32    (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:vaw')
    3333
    3434    lang = None
    3535    domain = 'django'
    3636    verbose = False
    3737    all = False
     38    nowrap = False
    3839
    3940    for o, v in opts:
    4041        if o == '-l':
     
    4546            verbose = True
    4647        elif o == '-a':
    4748            all = True
     49        elif o == '-w':
     50            nowrap = True
    4851
    4952    if domain not in ('django', 'djangojs'):
    5053        print "currently make-messages.py only supports domains 'django' and 'djangojs'"
     
    8588                src = pythonize_re.sub('\n#', src)
    8689                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
    8790                thefile = '%s.py' % file
    88                 cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
    89                     os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
     91                cmd = 'xgettext %s -d %s -L Perl %s --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
     92                    os.path.exists(potfile) and '--omit-header' or '', domain,
     93                    nowrap and '--no-wrap' or '', os.path.join(dirpath, thefile))
    9094                (stdin, stdout, stderr) = os.popen3(cmd, 't')
    9195                msgs = stdout.read()
    9296                errors = stderr.read()
     
    108112                    open(os.path.join(dirpath, thefile), "wb").write(templatize(src))
    109113                if verbose:
    110114                    sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
    111                 cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
    112                     domain, os.path.join(dirpath, thefile))
     115                cmd = 'xgettext -d %s -L Python %s --no-location --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
     116                    domain, nowrap and '--no-wrap' or '', os.path.join(dirpath, thefile))
    113117                (stdin, stdout, stderr) = os.popen3(cmd, 't')
    114118                msgs = stdout.read()
    115119                errors = stderr.read()
     
    132136                    os.unlink(os.path.join(dirpath, thefile))
    133137
    134138        if os.path.exists(potfile):
    135             (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b')
     139            (stdin, stdout, stderr) = os.popen3('msguniq %s --to-code=utf-8 "%s"' % (
     140                nowrap and '--no-wrap' or '', potfile), 'b')
    136141            msgs = stdout.read()
    137142            errors = stderr.read()
    138143            if errors:
     
    141146                sys.exit(8)
    142147            open(potfile, 'w').write(msgs)
    143148            if os.path.exists(pofile):
    144                 (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b')
     149                (stdin, stdout, stderr) = os.popen3('msgmerge %s -q "%s" "%s"' % (
     150                    nowrap and '--no-wrap' or '', pofile, potfile), 'b')
    145151                msgs = stdout.read()
    146152                errors = stderr.read()
    147153                if errors:
Back to Top