##// END OF EJS Templates
i18n: encode output in user's local encoding...
Martin Geisler -
r7651:5b5036ef default
parent child Browse files
Show More
@@ -22,5 +22,30 b" for dir in ('.', '..'):"
22 break
22 break
23
23
24 t = gettext.translation('hg', localedir, fallback=True)
24 t = gettext.translation('hg', localedir, fallback=True)
25 gettext = t.gettext
25
26 def gettext(message):
27 """Translate message.
28
29 The message is looked up in the catalog to get a Unicode string,
30 which is encoded in the local encoding before being returned.
31
32 Important: message is restricted to characters in the encoding
33 given by sys.getdefaultencoding() which is most likely 'ascii'.
34 """
35 # If message is None, t.ugettext will return u'None' as the
36 # translation whereas our callers expect us to return None.
37 if message is None:
38 return message
39
40 # We cannot just run the text through util.tolocal since that
41 # leads to infinite recursion when util._encoding is invalid.
42 try:
43 u = t.ugettext(message)
44 return u.encode(util._encoding, "replace")
45 except LookupError:
46 return message
47
26 _ = gettext
48 _ = gettext
49
50 # Moved after _ because of circular import.
51 import util
General Comments 0
You need to be logged in to leave comments. Login now