Fix l10n so getTranslationLanguage always returns a string

This commit is contained in:
bmng-dev 2014-08-08 01:34:57 +00:00
parent e58ac560de
commit 0d2c94f060

View File

@ -8,15 +8,19 @@ import shared
#logger = logging.getLogger(__name__) #logger = logging.getLogger(__name__)
logger = logging.getLogger('file_only') logger = logging.getLogger('file_only')
DEFAULT_ENCODING = 'ISO8859-1'
DEFAULT_LANGUAGE = 'en_US'
encoding = DEFAULT_ENCODING
language = DEFAULT_LANGUAGE
try: try:
import locale import locale
encoding = locale.getpreferredencoding(False) encoding = locale.getpreferredencoding(False) or DEFAULT_ENCODING
language = locale.getlocale()[0] or locale.getdefaultlocale()[0] language = locale.getlocale()[0] or locale.getdefaultlocale()[0] or DEFAULT_LANGUAGE
except: except:
logger.exception('Could not determine language or encoding') logger.exception('Could not determine language or encoding')
if not encoding:
encoding = 'ISO8859-1'
language = 'en_US'
time_format = shared.config.get('bitmessagesettings', 'timeformat') time_format = shared.config.get('bitmessagesettings', 'timeformat')