Improved reliability for language codes

This commit is contained in:
Maximilian Giller 2019-05-10 08:11:13 +02:00
parent 083f4bbf6f
commit 51d4e20553
2 changed files with 4 additions and 2 deletions

View file

@ -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 = []

View file

@ -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]