From c90199efc3d7a971df81b223fae0c2272f93cffd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 24 Jan 2012 10:15:11 +0530 Subject: [PATCH] Fix calibre not running on linux systems that set LANG to an empty string --- src/calibre/utils/localization.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/calibre/utils/localization.py b/src/calibre/utils/localization.py index 7ad0ea2bb9..dd07939559 100644 --- a/src/calibre/utils/localization.py +++ b/src/calibre/utils/localization.py @@ -27,7 +27,7 @@ def get_lang(): from calibre.utils.config_base import prefs lang = prefs['language'] lang = os.environ.get('CALIBRE_OVERRIDE_LANG', lang) - if lang is not None: + if lang: return lang try: lang = locale.getdefaultlocale(['LANGUAGE', 'LC_ALL', 'LC_CTYPE', @@ -45,7 +45,7 @@ def get_lang(): lang = match.group() if lang == 'zh': lang = 'zh_CN' - if lang is None: + if not lang: lang = 'en' return lang @@ -68,6 +68,8 @@ def set_translators(): # To test different translations invoke as # CALIBRE_OVERRIDE_LANG=de_DE.utf8 program lang = get_lang() + t = None + if lang: buf = iso639 = None mpath = get_lc_messages_path(lang) @@ -97,17 +99,16 @@ def set_translators(): except: pass # No iso639 translations for this lang - t = None if buf is not None: t = GNUTranslations(buf) if iso639 is not None: iso639 = GNUTranslations(iso639) t.add_fallback(iso639) - if t is None: - t = NullTranslations() + if t is None: + t = NullTranslations() - t.install(unicode=True, names=('ngettext',)) + t.install(unicode=True, names=('ngettext',)) _iso639 = None _extra_lang_codes = {