Improved reliability for language codes
This commit is contained in:
parent
083f4bbf6f
commit
51d4e20553
2 changed files with 4 additions and 2 deletions
|
@ -24,9 +24,9 @@ import IcalEvents
|
||||||
import RssParserPosts
|
import RssParserPosts
|
||||||
|
|
||||||
all_locales = locale.locale_alias
|
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)
|
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()
|
debug = DebugConsole()
|
||||||
output_adapters = []
|
output_adapters = []
|
||||||
|
|
|
@ -12,6 +12,8 @@ def translate(phrase, target_lang = language, dictionary_collection = dictionary
|
||||||
|
|
||||||
if target_lang in dictionary.keys():
|
if target_lang in dictionary.keys():
|
||||||
return dictionary[target_lang]
|
return dictionary[target_lang]
|
||||||
|
elif '_' in target_lang and target_lang.split('_')[0] in dictionary.keys():
|
||||||
|
return dictionary[target_lang.split('_')[0]]
|
||||||
else:
|
else:
|
||||||
return dictionary[default_language]
|
return dictionary[default_language]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue