mirror of https://github.com/django/django.git
Fixed #7030 -- Handle extraction of UTF-8 messages from Javascript files.
This leads to more duplicated code in make-messages.py, but this is just a holdover for the immediate problem until we merge make-messages into management/. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7473 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
138cecd892
commit
2945a057c3
|
@ -85,8 +85,7 @@ def make_messages():
|
||||||
src = pythonize_re.sub('\n#', src)
|
src = pythonize_re.sub('\n#', src)
|
||||||
open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
|
open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
|
||||||
thefile = '%s.py' % file
|
thefile = '%s.py' % file
|
||||||
cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
|
cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile))
|
||||||
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
|
|
||||||
(stdin, stdout, stderr) = os.popen3(cmd, 't')
|
(stdin, stdout, stderr) = os.popen3(cmd, 't')
|
||||||
msgs = stdout.read()
|
msgs = stdout.read()
|
||||||
errors = stderr.read()
|
errors = stderr.read()
|
||||||
|
@ -97,6 +96,11 @@ def make_messages():
|
||||||
old = '#: '+os.path.join(dirpath, thefile)[2:]
|
old = '#: '+os.path.join(dirpath, thefile)[2:]
|
||||||
new = '#: '+os.path.join(dirpath, file)[2:]
|
new = '#: '+os.path.join(dirpath, file)[2:]
|
||||||
msgs = msgs.replace(old, new)
|
msgs = msgs.replace(old, new)
|
||||||
|
if os.path.exists(potfile):
|
||||||
|
# Strip the header
|
||||||
|
msgs = '\n'.join(dropwhile(len, msgs.split('\n')))
|
||||||
|
else:
|
||||||
|
msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8')
|
||||||
if msgs:
|
if msgs:
|
||||||
open(potfile, 'ab').write(msgs)
|
open(potfile, 'ab').write(msgs)
|
||||||
os.unlink(os.path.join(dirpath, thefile))
|
os.unlink(os.path.join(dirpath, thefile))
|
||||||
|
|
Loading…
Reference in New Issue