i18n.py
brancholdstable
changeset 8462 a14b6562082b
parent 8225 baf8c16cae95
child 8620 61c4bdd70dd8
equal deleted inserted replaced
8231:1bb43e31032d 8462:a14b6562082b
    31     using standard python gettext marker (_)
    31     using standard python gettext marker (_)
    32     """
    32     """
    33     output = open(output_file, 'w')
    33     output = open(output_file, 'w')
    34     for filepath in files:
    34     for filepath in files:
    35         for match in re.finditer('i18n:(content|replace)="([^"]+)"', open(filepath).read()):
    35         for match in re.finditer('i18n:(content|replace)="([^"]+)"', open(filepath).read()):
    36             print >> output, '_("%s")' % match.group(2)
    36             output.write('_("%s")' % match.group(2))
    37     output.close()
    37     output.close()
    38 
    38 
    39 
    39 
    40 def add_msg(w, msgid, msgctx=None):
    40 def add_msg(w, msgid, msgctx=None):
    41     """write an empty pot msgid definition"""
    41     """write an empty pot msgid definition"""
    58 def execute(cmd):
    58 def execute(cmd):
    59     """display the command, execute it and raise an Exception if returned
    59     """display the command, execute it and raise an Exception if returned
    60     status != 0
    60     status != 0
    61     """
    61     """
    62     from subprocess import call
    62     from subprocess import call
    63     print cmd.replace(os.getcwd() + os.sep, '')
    63     # use getcwdu as cmd may be unicode and cwd may contains non-ascii
       
    64     # characters
       
    65     print cmd.replace(os.getcwdu() + os.sep, '')
    64     status = call(cmd, shell=True)
    66     status = call(cmd, shell=True)
    65     if status != 0:
    67     if status != 0:
    66         raise Exception('status = %s' % status)
    68         raise Exception('status = %s' % status)
    67 
    69 
    68 
    70