Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8.2, 0.8.3, and 0.9

stable i18n: fallback gracefully when unable to encode console output

Fixes #471

Changeset 546ebe206fcb

Parent 1113a4a050f7

by Steve Borho

Changes to one file · Browse files at 546ebe206fcb Showing diff from parent 1113a4a050f7 Diff from another changeset...

Change 1 of 1 Show Changes Only thgutil/​i18n.py Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 
26
27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
25
26
27
 # i18n.py - TortoiseHg internationalization code  #  # Copyright 2009 Steve Borho <steve@borho.org>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import gettext, sys  from gettext import gettext as _  from thgutil import paths, hglib    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 hglib.fromutf(u) - except LookupError: + except (LookupError, UnicodeEncodeError):   return message