Skip to content

Commit

Permalink
Fix: check availability of both source and destination language
Browse files Browse the repository at this point in the history
refs #2
  • Loading branch information
ssut committed Jul 17, 2015
1 parent 7a59b8a commit 6a101f4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions googletrans/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def translate(text, dest='en', src='auto'):
result.append(translated)
return result

if dest not in LANGUAGES.keys():
raise ValueError('incorrect destination language')
if src != 'auto' and src not in LANGUAGES.keys():
raise ValueError('incorrect source language')

result = ''
sess = agent() # acquire requests session
origin = text
Expand Down

0 comments on commit 6a101f4

Please sign in to comment.