Improved code

This commit is contained in:
Maximilian Giller 2019-05-10 08:19:22 +02:00
parent 51d4e20553
commit 4d3c2cfbd7

View file

@ -5,7 +5,7 @@ from settings import language
and returns the translated phrase'''
def translate(phrase, target_lang = language, dictionary_collection = dictionary_collection) :
dictionary = find_dictionary(dictionary_collection, phrase)
dictionary = find_dictionary(phrase, dictionary_collection)
if dictionary == None:
return phrase
@ -17,8 +17,7 @@ def translate(phrase, target_lang = language, dictionary_collection = dictionary
else:
return dictionary[default_language]
def find_dictionary(dictionary_collection, phrase):
def find_dictionary(phrase, dictionary_collection = dictionary_collection):
for dictionary in dictionary_collection:
if phrase in dictionary.values():
return dictionary