Happy New Year dear PyKDE Developers :)

Anthony Mercatante and I were sitting yesterday on IRC and were
discussing the usage of the default KDE translation workflow.
KDE normally uses the i18n gettext method, and we (Kubuntu Folks)
wanted to use it inside python-kde3 as well.

So we prepared a patch for kdepyuic which does exactly this.
Furthermore we fixed the wrong usage of the getopts stuff inside
kdepyuic.

Please find attached a patch for kdepyuic...we would like to see this
pushed upstream.

Thanks for all your work and we wish you all a good year 2008...

\sh

-- 
Stephan Hermann
SysAdmin and OSS Developer
http://www.sourcecode.de/
JID: [EMAIL PROTECTED]
diff -ruN PyKDE-3.16.0/contrib/kdepyuic PyKDE-3.16.0.patched/contrib/kdepyuic
--- PyKDE-3.16.0/contrib/kdepyuic	2006-05-25 03:27:51.000000000 +0200
+++ PyKDE-3.16.0.patched/contrib/kdepyuic	2008-01-04 17:05:33.789458921 +0100
@@ -37,7 +37,7 @@
 addImport  = TRUE
 pyuicPath  = "pyuic"
 filename   = ""
-
+i18nFunc   = FALSE
 
 # --------- support functions ----------
 
@@ -45,8 +45,8 @@
     global filename
 
     opterr = 0
-    shortOptions = "aip:"
-    longOptions  = "noapp noimport pyuic="
+    shortOptions = 'aip:'
+    longOptions  = ['noapp','noimport','pyuic="','usekdei18n']
 
     try:
         optlist, args = getopt.getopt (sys.argv [1:], shortOptions, longOptions)
@@ -64,6 +64,7 @@
     -a, --noapp Don't add KApplication code
     -i, --noimport  Don't add kdecore, kdeui import statements
     -p, --pyuic Path to pyuic program
+    --usekdei18n Adds KDEs default i18n functions to your Python KDE ui file
   """
         return FALSE
 
@@ -71,7 +72,7 @@
     return checkOptions (optlist)
 
 def checkOptions (optlist):
-    global addApp, addImport, pyuicPath
+    global addApp, addImport, pyuicPath, i18nFunc
 
     for pair in optlist:
         if (pair [0] == '--noapp') or (pair [0] == '-a'):
@@ -82,7 +83,11 @@
 
         elif (pair [0] == '--pyuic') or (pair [0] == '-p'):
             pyuicPath = pair [1]
-
+	    	   
+        if (pair [0] == '--usekdei18n'):
+	   i18nFunc=TRUE
+        else:
+            i18nFunc=FALSE
 
 
 # --------- operations ----------
@@ -90,6 +95,10 @@
 def addimport (n):
     if addApp:
         n.write ('from kdecore import KCmdLineArgs, KApplication\n')
+
+    if i18nFunc:
+        n.write ('from kdecore import i18n\n')
+
     n.write ('from kdeui import *\n\n')
 
 
@@ -105,10 +114,14 @@
 
     fn = os.path.splitext (os.path.basename(filename)) [0] + '.py'
 
+    opts = ""
+
+    if i18nFunc:
+       opts = opts + ' -tr i18n '
     if addApp:
-        opts = ' -x -o '
-    else:
-        opts = ' -o '
+        opts = opts + ' -x '
+        
+    opts = opts + ' -o '
 
     if os.system (pyuicPath + opts + fn + ' ' + filename) != 0:
         print pyuicPath + opts + fn + ' ' + filename + " failed"
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to