making PO/POT/... update scripts py3.2 compatible + making it almost win compatible
authorDalai Felinto <dfelinto@gmail.com>
Thu, 29 Sep 2011 06:34:58 +0000 (06:34 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Thu, 29 Sep 2011 06:34:58 +0000 (06:34 +0000)
Adding from codecs import open + the encoding in update_pot.py so it works for python 3.2.
Now it should be easier to replace the executable folders in the first lines of the file.
It now also works if you are in the same folder as the .po files (i.e. os.path.dirname(__FILE__) is empty)

It's still not working for me on Mingw because I need gettext 1.8 and so far I found only the 1.7
(in 1.7 msgmerge --lang is not supported)

po/update_mo.py
po/update_msg.py
po/update_po.py
po/update_pot.py

index fc70891de8f1cf1ff55c4e7c8e82957a86614d2f..33b7baaed693a2ce26310c8f67724e12d3022e88 100755 (executable)
@@ -27,7 +27,8 @@ import subprocess
 import os
 import sys
 
-CURRENT_DIR = os.path.dirname(__file__)
+GETTEXT_MSGFMT_EXECUTABLE = "msgfmt"
+CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
 SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.join(CURRENT_DIR, "..")))
 LOCALE_DIR = os.path.join(SOURCE_DIR, "release", "bin", ".blender", "locale")
 
@@ -38,7 +39,7 @@ def process_po(po):
     lang = os.path.basename(po)[:-3]
 
     # show stats
-    cmd = ("msgfmt",
+    cmd = (GETTEXT_MSGFMT_EXECUTABLE,
         "--statistics",
         os.path.join(CURRENT_DIR, "%s.po" % lang),
         "-o",
index a58fd4b799832db7a30b29322e3508e0a64164fc..fc3e26b198017cda04d4665cbe7c52d06bb0f1a8 100644 (file)
@@ -26,7 +26,7 @@
 
 import os
 
-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, "..")))
 
 FILE_NAME_MESSAGES = os.path.join(CURRENT_DIR, "messages.txt")
index 45738363966c36dbea366ec9de6f8a9a9dfe5951..978de6ab1e5558b1281ae2a4ac9d40498eaf0037 100755 (executable)
@@ -27,7 +27,8 @@ import subprocess
 import os
 import sys
 
-CURRENT_DIR = os.path.dirname(__file__)
+GETTEXT_MSGMERGE_EXECUTABLE = "msgmerge"
+CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
 DOMAIN = "blender"
 
 
@@ -35,7 +36,7 @@ def process_po(po):
     lang = os.path.basename(po)[:-3]
 
     # update po file
-    cmd = ("msgmerge",
+    cmd = (GETTEXT_MSGMERGE_EXECUTABLE,
            "--update",
            "--lang=%s" % lang,
            os.path.join(CURRENT_DIR, "%s.po" % lang),
index 6c1d473b7f88d76f4b9c7e0dde0e32b6d2e80eba..33f0b3974628e5a397082bebb93909b43c6420f8 100755 (executable)
 
 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"
 
@@ -55,7 +56,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 +74,8 @@ 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:
             while True:
                 line = handle.readline()