Django

Code

Changeset 5708

Show
Ignore:
Timestamp:
07/15/07 05:10:44 (10 months ago)
Author:
mtredinnick
Message:

Fixed #4734 -- Changed message extraction to permit non-ACSII msgid strings.
Thanks, krzysiek.pawlik@silvermedia.pl.

This is slightly backwards-incompatible for translators: PO files are now
assumed to be in UTF-8 encoding.

Files:

Legend:

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

    r5609 r5708  
    104104                        thefile = '%s.py' % file 
    105105                    if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath)) 
    106                     cmd = 'xgettext %s -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"' % ( 
    107                         os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile)) 
     106                    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"' % ( 
     107                        domain, os.path.join(dirpath, thefile)) 
    108108                    (stdin, stdout, stderr) = os.popen3(cmd, 'b') 
    109109                    msgs = stdout.read() 
     
    117117                        new = '#: '+os.path.join(dirpath, file)[2:] 
    118118                        msgs = msgs.replace(old, new) 
     119                    if os.path.exists(potfile): 
     120                        # Strip the header 
     121                        msgs = '\n'.join(msgs.split('\n')[17:]) 
     122                    else: 
     123                        msgs = msgs.replace('charset=CHARSET', 'charset=UTF-8') 
    119124                    if msgs: 
    120125                        open(potfile, 'ab').write(msgs) 
     
    123128 
    124129        if os.path.exists(potfile): 
    125             (stdin, stdout, stderr) = os.popen3('msguniq "%s"' % potfile, 'b') 
     130            (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b') 
    126131            msgs = stdout.read() 
    127132            errors = stderr.read()