Django

Code

Changeset 7473

Show
Ignore:
Timestamp:
04/26/08 08:25:30 (2 months ago)
Author:
mtredinnick
Message:

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/.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/bin/make-messages.py

    r6445 r7473  
    8686                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src) 
    8787                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)) 
     88                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)) 
    9089                (stdin, stdout, stderr) = os.popen3(cmd, 't') 
    9190                msgs = stdout.read() 
     
    9897                new = '#: '+os.path.join(dirpath, file)[2:] 
    9998                msgs = msgs.replace(old, new) 
     99                if os.path.exists(potfile): 
     100                    # Strip the header 
     101                    msgs = '\n'.join(dropwhile(len, msgs.split('\n'))) 
     102                else: 
     103                    msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 
    100104                if msgs: 
    101105                    open(potfile, 'ab').write(msgs)