py3: handle ugettext + unicode in i18n
authortimeless <timeless@mozdev.org>
Tue, 29 Mar 2016 17:22:08 +0000
changeset 28674 03d1ecbbd81e
parent 28673 e78613c13f1d
child 28675 fcafd84bc9c5
py3: handle ugettext + unicode in i18n
mercurial/i18n.py
--- a/mercurial/i18n.py	Mon Mar 28 22:30:23 2016 +0000
+++ b/mercurial/i18n.py	Tue Mar 29 17:22:08 2016 +0000
@@ -20,6 +20,10 @@
 else:
     module = __file__
 
+try:
+    unicode
+except NameError:
+    unicode = str
 
 _languages = None
 if (os.name == 'nt'
@@ -45,7 +49,10 @@
     localedir = os.path.join(datapath, 'locale')
     t = gettextmod.translation('hg', localedir, _languages, fallback=True)
     global _ugettext
-    _ugettext = t.ugettext
+    try:
+        _ugettext = t.ugettext
+    except AttributeError:
+        _ugettext = t.gettext
 
 _msgcache = {}