Changeset 92f839272b73…
Parent e63b33ef3201…
by
Changes to 2 files · Browse files at 92f839272b73 Showing diff from parent e63b33ef3201 Diff from another changeset...
@@ -21,7 +21,7 @@ import mercurial.ui as _ui
from mercurial import hg, util, fancyopts, cmdutil, extensions
-from thgutil.i18n import _
+from thgutil.i18n import agettext as _
from thgutil import hglib, paths, shlib
from thgutil import version as thgversion
|
@@ -6,9 +6,23 @@ of the GNU General Public License, incorporated herein by reference.
"""
-import gettext
+import gettext, sys
from gettext import gettext as _
import paths
gettext.bindtextdomain("tortoisehg", paths.get_locale_path())
gettext.textdomain("tortoisehg")
+
+def agettext(message):
+ """Translate message and convert to local encoding
+ such as 'ascii' before being returned.
+
+ Only use this if you need to output translated messages
+ to command-line interface (ie: Windows Command Prompt).
+ """
+ try:
+ u = _(message)
+ return u.encode(sys.stdout.encoding, "replace")
+ except LookupError:
+ return message
+
|
Loading...