Ticket #6476: nowrap.patch
File nowrap.patch, 3.6 KB (added by , 17 years ago) |
---|
-
bin/make-messages.py
29 29 print "you want to enable i18n for your project or application." 30 30 sys.exit(1) 31 31 32 (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:va ')32 (opts, args) = getopt.getopt(sys.argv[1:], 'l:d:vaw') 33 33 34 34 lang = None 35 35 domain = 'django' 36 36 verbose = False 37 37 all = False 38 nowrap = False 38 39 39 40 for o, v in opts: 40 41 if o == '-l': … … 45 46 verbose = True 46 47 elif o == '-a': 47 48 all = True 49 elif o == '-w': 50 nowrap = True 48 51 49 52 if domain not in ('django', 'djangojs'): 50 53 print "currently make-messages.py only supports domains 'django' and 'djangojs'" … … 85 88 src = pythonize_re.sub('\n#', src) 86 89 open(os.path.join(dirpath, '%s.py' % file), "wb").write(src) 87 90 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)) 90 94 (stdin, stdout, stderr) = os.popen3(cmd, 't') 91 95 msgs = stdout.read() 92 96 errors = stderr.read() … … 108 112 open(os.path.join(dirpath, thefile), "wb").write(templatize(src)) 109 113 if verbose: 110 114 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)) 113 117 (stdin, stdout, stderr) = os.popen3(cmd, 't') 114 118 msgs = stdout.read() 115 119 errors = stderr.read() … … 132 136 os.unlink(os.path.join(dirpath, thefile)) 133 137 134 138 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') 136 141 msgs = stdout.read() 137 142 errors = stderr.read() 138 143 if errors: … … 141 146 sys.exit(8) 142 147 open(potfile, 'w').write(msgs) 143 148 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') 145 151 msgs = stdout.read() 146 152 errors = stderr.read() 147 153 if errors: