parent
649ba7d828
commit
80a76450d2
@ -12,7 +12,7 @@ from future.moves.urllib.parse import quote
|
|||||||
from . import __version__
|
from . import __version__
|
||||||
from googletrans import urls
|
from googletrans import urls
|
||||||
from googletrans.conversion import format_json
|
from googletrans.conversion import format_json
|
||||||
from googletrans.conversion import LANGUAGES
|
from googletrans.conversion import LANGUAGES, SPECIAL_CASES
|
||||||
from googletrans.response import Translated, Detected
|
from googletrans.response import Translated, Detected
|
||||||
|
|
||||||
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36 Gt/{0}'.format(__version__)
|
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36 Gt/{0}'.format(__version__)
|
||||||
@ -74,11 +74,16 @@ Advanced usage:
|
|||||||
result.append(translated)
|
result.append(translated)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if dest not in LANGUAGES.keys():
|
if src != 'auto' and src not in LANGUAGES.keys() and src in SPECIAL_CASES.keys():
|
||||||
raise ValueError('incorrect destination language')
|
src = SPECIAL_CASES[src]
|
||||||
if src != 'auto' and src not in LANGUAGES.keys():
|
elif src != 'auto' and src not in LANGUAGES.keys():
|
||||||
raise ValueError('incorrect source language')
|
raise ValueError('incorrect source language')
|
||||||
|
|
||||||
|
if dest not in LANGUAGES.keys() and dest in SPECIAL_CASES.keys():
|
||||||
|
dest = SPECIAL_CASES[dest]
|
||||||
|
elif dest not in LANGUAGES.keys():
|
||||||
|
raise ValueError('incorrect destination language')
|
||||||
|
|
||||||
result = ''
|
result = ''
|
||||||
sess = agent() # acquire requests session
|
sess = agent() # acquire requests session
|
||||||
origin = text
|
origin = text
|
||||||
|
Loading…
Reference in New Issue
Block a user