Alias ugettext to gettext method of cwGNUTranslations in Python 3 3.24
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 17 Nov 2016 10:47:52 +0100
branch3.24
changeset 11823 4f43e64603ef
parent 11822 adf0212d1dcc
child 11824 d7ecf6dab085
Alias ugettext to gettext method of cwGNUTranslations in Python 3 The former does not exist in Python 3, but we rely on it. This fixes test_login_bad_password in cubicweb/pyramid/test/test_login.py which has never passed since being introduced in 6392f34fcdad.
cubicweb/cwgettext.py
--- a/cubicweb/cwgettext.py	Wed Nov 16 14:38:11 2016 +0100
+++ b/cubicweb/cwgettext.py	Thu Nov 17 10:47:52 2016 +0100
@@ -18,6 +18,8 @@
 
 import gettext
 
+from six import PY3
+
 
 class cwGNUTranslations(gettext.GNUTranslations):
     # The encoding of a msgctxt and a msgid in a .mo file is
@@ -83,6 +85,9 @@
             else:
                 return msgid2
 
+    if PY3:
+        ugettext = gettext.GNUTranslations.gettext
+
     def upgettext(self, context, message):
         ctxt_message_id = self.CONTEXT_ENCODING % (context, message)
         missing = object()