mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Another couple of ispy3
This commit is contained in:
parent
c4eedda5f2
commit
151fa406f6
@ -8,7 +8,6 @@ __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
||||
|
||||
import io
|
||||
from gettext import GNUTranslations
|
||||
from calibre.constants import ispy3
|
||||
from calibre.utils.localization import get_lc_messages_path
|
||||
from zipfile import ZipFile
|
||||
|
||||
@ -35,5 +34,4 @@ def translate(lang, text):
|
||||
_CACHE[lang] = trans
|
||||
if trans is None:
|
||||
return getattr(__builtins__, '_', lambda x: x)(text)
|
||||
f = getattr(trans, 'gettext' if ispy3 else 'ugettext')
|
||||
return f(text)
|
||||
return trans.gettext(text)
|
||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, locale, re, io, sys
|
||||
import os, locale, re, io
|
||||
from gettext import GNUTranslations, NullTranslations
|
||||
|
||||
from polyglot.builtins import iteritems, unicode_type
|
||||
@ -402,8 +402,7 @@ def get_language(lang, gettext_func=None):
|
||||
# re-translate
|
||||
return translate(_extra_lang_codes[lang])
|
||||
if gettext_func is None:
|
||||
attr = 'gettext' if sys.version_info.major > 2 else 'ugettext'
|
||||
gettext_func = getattr(_lang_trans, attr, translate)
|
||||
gettext_func = getattr(_lang_trans, 'gettext', translate)
|
||||
return get_iso_language(gettext_func, lang)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user