Commits

Stefan Rusek  committed cd79462

wrap calls to i18n.gettext()

This is the naive approach if this turns out to be too slow we can switch
to the smarter approach, the reason why the naive approach is preferred is
that it results in less duplicated code.

  • Participants
  • Parent commits d203a65

Comments (0)

Files changed (1)

 '''
 
 import sys, os, shutil
-from mercurial import util, osutil, dispatch, extensions
+from mercurial import util, osutil, dispatch, extensions, i18n
 import stat as _stat
 import mercurial.ui as _ui
 
 def utf8wrapper(orig, *args, **kargs):
     return fromunicode(orig(*tounicode(args), **kargs))
 
+def gettextwrapper(orig, message):
+    s = orig(message)
+    return s.decode(util._encoding).encode("utf-8")
+
 # The following 2 functions are copied from mercurial/pure/osutil.py.
 # The reasons is that the C version of listdir is not unicode safe, so
 # we have to use the pure python version. If speed ends up being a
 
     extensions.wrapfunction(_ui.ui, "write", localize)
     extensions.wrapfunction(_ui.ui, "write_err", localize)
+    extensions.wrapfunction(i18n, "gettext", gettextwrapper)
+    extensions.wrapfunction(i18n, "_", gettextwrapper)
 
 def extsetup():
     if util._encoding.lower() == "utf-8":