From 51d4e205535c41a7922164fb5542c20c12619b0e Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 10 May 2019 08:11:13 +0200 Subject: [PATCH] Improved reliability for language codes --- Calendar/E-Paper.py | 4 ++-- Calendar/Translator.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Calendar/E-Paper.py b/Calendar/E-Paper.py index ea477c6..a43bcc2 100644 --- a/Calendar/E-Paper.py +++ b/Calendar/E-Paper.py @@ -24,9 +24,9 @@ import IcalEvents import RssParserPosts all_locales = locale.locale_alias -if language not in all_locales.keys(): +if language.lower() not in all_locales.keys(): raise Exception("The locale for \"%s\" is currently not supported! If you need support, please open an issue on github." % language) -locale.setlocale(locale.LC_ALL, "%s.%s" % (all_locales[language].split('.')[0], datetime_encoding)) +locale.setlocale(locale.LC_ALL, "%s.%s" % (all_locales[language.lower()].split('.')[0], datetime_encoding)) debug = DebugConsole() output_adapters = [] diff --git a/Calendar/Translator.py b/Calendar/Translator.py index 218a6a0..9d27774 100644 --- a/Calendar/Translator.py +++ b/Calendar/Translator.py @@ -12,6 +12,8 @@ def translate(phrase, target_lang = language, dictionary_collection = dictionary if target_lang in dictionary.keys(): return dictionary[target_lang] + elif '_' in target_lang and target_lang.split('_')[0] in dictionary.keys(): + return dictionary[target_lang.split('_')[0]] else: return dictionary[default_language]