diff options
Diffstat (limited to 'po/update_pot.py')
-rwxr-xr-x | po/update_pot.py | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/po/update_pot.py b/po/update_pot.py index b0d77a3be03..4e202026444 100755 --- a/po/update_pot.py +++ b/po/update_pot.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# $Id: +# $Id$ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or @@ -25,11 +25,13 @@ import subprocess import os +from codecs import open GETTEXT_XGETTEXT_EXECUTABLE = "xgettext" -CURRENT_DIR = os.path.dirname(__file__) +CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, ".."))) DOMAIN = "blender" +COMMENT_PREFIX = "#~ " # from update_msg.py FILE_NAME_POT = os.path.join(CURRENT_DIR, "blender.pot") FILE_NAME_MESSAGES = os.path.join(CURRENT_DIR, "messages.txt") @@ -55,7 +57,7 @@ def main(): pot_messages = {} reading_message = False message = "" - with open(FILE_NAME_POT, 'r') as handle: + with open(FILE_NAME_POT, 'r', "utf-8") as handle: while True: line = handle.readline() @@ -73,8 +75,9 @@ def main(): message += line[1:-1] # add messages collected automatically from RNA - with open(FILE_NAME_POT, "a") as pot_handle: - with open(FILE_NAME_MESSAGES, 'r') as handle: + with open(FILE_NAME_POT, "a", "utf-8") as pot_handle: + with open(FILE_NAME_MESSAGES, 'r', "utf-8") as handle: + msgsrc_ls = [] while True: line = handle.readline() @@ -82,14 +85,23 @@ def main(): break line = stripeol(line) - line = line.replace("\\", "\\\\") - line = line.replace("\"", "\\\"") - if not pot_messages.get(line): - pot_handle.write("\n#: Automatically collected from RNA\n") - pot_handle.write("msgid \"%s\"\n" % (line)) - pot_handle.write("msgstr \"\"\n") + # COMMENT_PREFIX + if line.startswith(COMMENT_PREFIX): + msgsrc_ls.append(line[len(COMMENT_PREFIX):].strip()) + else: + line = line.replace("\\", "\\\\") + line = line.replace("\"", "\\\"") + line = line.replace("\t", "\\t") + + if not pot_messages.get(line): + for msgsrc in msgsrc_ls: + pot_handle.write("#: %s\n" % msgsrc) + pot_handle.write("msgid \"%s\"\n" % line) + pot_handle.write("msgstr \"\"\n\n") + msgsrc_ls[:] = [] if __name__ == "__main__": + print("\n\n *** Running %r *** \n" % __file__) main() |