[PATCH 07 of 13] Initial attempt to fix i18n unicode changes on Py3k. Work on progress

Alejandro Santos alejolp at alejolp.com
Wed Aug 5 15:55:41 CDT 2009


# HG changeset patch
# User Alejandro Santos <alejolp at alejolp.com>
# Date 1249505636 10800
# Node ID 11bc534a8f1d09a9d7c24b0e0c55d258a0782ab3
# Parent  d0b6c743b767fef7516206872765e4c8136c515f
Initial attempt to fix i18n unicode changes on Py3k. Work on progress.

diff -r d0b6c743b767 -r 11bc534a8f1d mercurial/i18n.py
--- a/mercurial/i18n.py	Wed Aug 05 17:53:56 2009 -0300
+++ b/mercurial/i18n.py	Wed Aug 05 17:53:56 2009 -0300
@@ -22,7 +22,7 @@
 
 t = gettext.translation('hg', localedir, fallback=True)
 
-def gettext(message):
+def gettext2(message):
     """Translate message.
 
     The message is looked up in the catalog to get a Unicode string,
@@ -44,5 +44,22 @@
     except LookupError:
         return message
 
-_ = gettext
+def gettext3(message):
+    """
+    Translate message.
+    """
+    # If message is None, t.gettext will return 'None' as the
+    # translation whereas our callers expect us to return None.
+    if message is None:
+        return message
 
+    try:
+        return t.gettext(message)
+    except LookupError:
+        return message
+
+if sys.version_info[0] == 2:
+    _ = gettext = gettext2
+else:
+    _ = gettext = gettext3
+


More information about the Mercurial-devel mailing list