From d6cd29e392edd258414da1fc435968104b15c04d Mon Sep 17 00:00:00 2001 From: yorikvanhavre Date: Fri, 21 Oct 2011 18:45:59 +0000 Subject: [PATCH] + included pylupdate commands for python workbenches in updatets script git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5051 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Tools/updatets.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Tools/updatets.py b/src/Tools/updatets.py index c3fe1a041f..d9701ba8c0 100644 --- a/src/Tools/updatets.py +++ b/src/Tools/updatets.py @@ -17,6 +17,7 @@ Version: import os, re +# folders that should not be treated by standard Qt tools DirFilter = ["^Attic$", "^CVS$", "^\\.svn$", @@ -30,12 +31,21 @@ DirFilter = ["^Attic$", "src/Mod/Draft", "src/Mod/Arch", "src/Mod/Start"] + +# folders that need a special pylupdate command +PyCommands = [["src/Mod/Draft", + "pylupdate *.py draftlibs/*.py Resources/ui/*.ui -ts Resources/translations/Draft.ts"], + ["src/Mod/Arch", + "pylupdate *.py Resources/ui/*.ui -ts Resources/translations/Arch.ts"], + ["src/Mod/Start", + "pylupdate StartPage/*.py -ts Gui/Resources/translations/StartPage.ts"]] QMAKE = "" LUPDATE = "" +PYLUPDATE = "" def find_tools(): - global QMAKE, LUPDATE + global QMAKE, LUPDATE, PYLUPDATE if (os.system("qmake-qt4 -version") == 0): QMAKE = "qmake-qt4" elif (os.system("qmake -version") == 0): @@ -48,7 +58,13 @@ def find_tools(): LUPDATE = "lupdate" else: raise Exception("Cannot find lupdate") - print "Qt tools:", QMAKE, LUPDATE + if (os.system("pylupdate -version") == 0): + PYLUPDATE = "pylupdate" + elif (os.system("pylupdate4 -version") == 0): + PYLUPDATE = "pylupdate4" + else: + raise Exception("Cannot find pylupdate") + print "Qt tools:", QMAKE, LUPDATE, PYLUPDATE def filter_dirs(item): global DirFilter @@ -70,6 +86,15 @@ def update_translation(path): os.remove(filename) os.chdir(cur) +def update_python_translation(item): + global PYLUPDATE + cur = os.getcwd() + os.chdir(item[0]) + execline = item[1].replace("pylupdate",PYLUPDATE) + print "Executing special command in ",item[0],": ",execline + os.system(execline) + os.chdir(cur) + def main(): find_tools() path = os.path.realpath(__file__) @@ -86,6 +111,8 @@ def main(): dirs = filter(filter_dirs, dirs) for i in dirs: update_translation(i) + for j in PyCommands: + update_python_translation(j) if __name__ == "__main__": main()