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'''
|
and returns the translated phrase'''
|
||||||
|
|
||||||
def translate(phrase, target_lang = language, dictionary_collection = dictionary_collection) :
|
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:
|
if dictionary == None:
|
||||||
return phrase
|
return phrase
|
||||||
|
@ -17,8 +17,7 @@ def translate(phrase, target_lang = language, dictionary_collection = dictionary
|
||||||
else:
|
else:
|
||||||
return dictionary[default_language]
|
return dictionary[default_language]
|
||||||
|
|
||||||
|
def find_dictionary(phrase, dictionary_collection = dictionary_collection):
|
||||||
def find_dictionary(dictionary_collection, phrase):
|
|
||||||
for dictionary in dictionary_collection:
|
for dictionary in dictionary_collection:
|
||||||
if phrase in dictionary.values():
|
if phrase in dictionary.values():
|
||||||
return dictionary
|
return dictionary
|
||||||
|
|
Loading…
Reference in a new issue