diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-29 21:15:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-29 21:15:58 +0400 |
commit | 9a0776c54a3aaeacbfd3575098b8ae428b217878 (patch) | |
tree | a79f72eb8bd259e4579fac9d8a6a4d4d8880b714 /po/update_pot.py | |
parent | 6f9636b800c8a5000a278b0a49843db2c2450431 (diff) |
improvements to translation message generator
- for rna stringsinclude the path as comment, eg:
#~ bpy.types.VertexGroup.name
- skip strings like %dx%d or -X.
- for strings extracted from python scripts include file:line reference as with C files.
- have messages in order they appear in the file, files and classes sorted so it reads more logically.
- extract these comments from the messages.txt file into the pot file.
Diffstat (limited to 'po/update_pot.py')
-rwxr-xr-x | po/update_pot.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/po/update_pot.py b/po/update_pot.py index 33f0b397462..22e1e7a1c1f 100755 --- a/po/update_pot.py +++ b/po/update_pot.py @@ -31,6 +31,7 @@ GETTEXT_XGETTEXT_EXECUTABLE = "xgettext" 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") @@ -76,6 +77,7 @@ def main(): # add messages collected automatically from RNA 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() @@ -83,13 +85,20 @@ 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("\"", "\\\"") + + 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__": |