summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-12-21 07:43:16 +0900
committerkali <kali@leap.se>2012-12-21 07:43:16 +0900
commitb0c3c9194447f20306111a31ee5a6d4828fed158 (patch)
treecb4b8582cbad1264184818f416fdaedcbb53998d
parenta7b091a0553e6120f3e0eb6d4e73a89732c589b2 (diff)
readme typos, updated translation docs
-rw-r--r--README.rst6
-rw-r--r--src/leap/util/translations.py58
2 files changed, 61 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 01e1c151..9ef3f99b 100644
--- a/README.rst
+++ b/README.rst
@@ -15,12 +15,12 @@ You can read the documentation online at `http://leap-client.readthedocs.org <ht
Quick Start
==============
-At the current development stage we still do not have any versioned release. Instead, you might want to have a look at the `testers guide<http://leap-client.readthedocs.org/en/latest/testers/howto.html>`_ for a quick howto on fetching and testing latest development code.
+At the current development stage we still do not have any versioned release. Instead, you might want to have a look at the `testers guide <http://leap-client.readthedocs.org/en/latest/testers/howto.html>`_ for a quick howto on fetching and testing latest development code.
Dependencies
------------------
-Leap client depends on these libraries:
+LEAP Client depends on these libraries:
* ``python 2.6`` or ``2.7``
* ``qt4 libraries``
@@ -73,7 +73,7 @@ After a successful installation, there should be a launcher called ``leap-client
Hacking
=======
-See the `hackers guide<http://leap-client.readthedocs.org/en/latest/dev/environment.html>`_
+See the `hackers guide <http://leap-client.readthedocs.org/en/latest/dev/environment.html>`_.
The LEAP client git repository is available at::
diff --git a/src/leap/util/translations.py b/src/leap/util/translations.py
new file mode 100644
index 00000000..c06aa947
--- /dev/null
+++ b/src/leap/util/translations.py
@@ -0,0 +1,58 @@
+import inspect
+
+from PyQt4.QtCore import QCoreApplication
+
+"""
+here I could not do all that I wanted.
+the context is not getting passed to the xml file.
+Looks like pylupdate4 is somehow a hack that does not
+parse too well the python ast.
+I guess we could generate the xml for ourselves as a last recourse.
+"""
+
+# XXX BIG NOTE:
+# RESIST the temptation to get the translate function
+# more compact, or have the Context argument passed as a variable
+# It HAS to be explicit due to how the pylupdate parser
+# works.
+
+
+qtTranslate = QCoreApplication.translate
+
+
+class LEAPTr:
+ pass
+
+
+def translate(*args):
+ """
+ translate(Context, text, comment)
+ """
+ print 'translating...'
+ klsname = None
+ try:
+ # get class value from instance
+ # using live object inspection
+ prev_frame = inspect.stack()[1][0]
+ self = inspect.getargvalues(prev_frame).locals.get('self')
+ if self:
+ # XXX will this work with QObject wrapper??
+ if isinstance(LEAPTr, self) and hasattr(self, 'tr'):
+ print "we got a self in base class"
+ return self.tr(*args)
+
+ # Trying to get the class name
+ # but this is useless, the parser
+ # has already got the context.
+ klsname = self.__class__.__name__
+ print 'KLSNAME -- ', klsname
+ except:
+ print 'error getting stack frame'
+
+ if klsname:
+ nargs = (klsname,) + args
+ return qtTranslate(*nargs)
+
+ else:
+ nargs = ('default', ) + args
+ return qtTranslate(*nargs)