Improved code
This commit is contained in:
parent
51d4e20553
commit
4d3c2cfbd7
1 changed files with 2 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue