Fix UnicodeDecodeError with ngettext and python2

This commit is contained in:
Patrick Decat 2019-05-05 11:27:32 +02:00 committed by Peter Wu
parent 60c52eb13f
commit 6c0acee645
4 changed files with 6 additions and 5 deletions

View File

@ -27,8 +27,10 @@ import gettext as _gettext
try: try:
unicode unicode
_ = lambda x: _gettext.gettext(x).decode('UTF-8') _ = lambda x: _gettext.gettext(x).decode('UTF-8')
ngettext = lambda *x: _gettext.ngettext(*x).decode('UTF-8')
except: except:
_ = _gettext.gettext _ = _gettext.gettext
ngettext = _gettext.ngettext
# A few common strings, not always accessible as such in the code. # A few common strings, not always accessible as such in the code.

View File

@ -26,8 +26,7 @@ _log = getLogger(__name__)
del getLogger del getLogger
from .i18n import _ from .i18n import _, ngettext
from gettext import ngettext
from .common import NamedInts as _NamedInts, NamedInt as _NamedInt from .common import NamedInts as _NamedInts, NamedInt as _NamedInt
from . import hidpp10 as _hidpp10 from . import hidpp10 as _hidpp10
from . import hidpp20 as _hidpp20 from . import hidpp20 as _hidpp20

View File

@ -60,5 +60,7 @@ _gettext.install(_LOCALE_DOMAIN)
try: try:
unicode unicode
_ = lambda x: _gettext.gettext(x).decode('UTF-8') _ = lambda x: _gettext.gettext(x).decode('UTF-8')
ngettext = lambda *x: _gettext.ngettext(*x).decode('UTF-8')
except: except:
_ = _gettext.gettext _ = _gettext.gettext
ngettext = _gettext.ngettext

View File

@ -26,10 +26,8 @@ del getLogger
from gi.repository import Gtk, Gdk, GLib from gi.repository import Gtk, Gdk, GLib
from gi.repository.GObject import TYPE_PYOBJECT from gi.repository.GObject import TYPE_PYOBJECT
from solaar import NAME from solaar import NAME
from solaar.i18n import _ from solaar.i18n import _, ngettext
from gettext import ngettext
# from solaar import __version__ as VERSION # from solaar import __version__ as VERSION
from solaar.ui import ui_async as _ui_async from solaar.ui import ui_async as _ui_async
from logitech_receiver import hidpp10 as _hidpp10 from logitech_receiver import hidpp10 as _hidpp10