lushan88a / google_trans_new

A free and unlimited python API for google translate.
MIT License
393 stars 170 forks source link

Text language detected as 'rw', but that's not a valid language? #31

Open brieh opened 3 years ago

brieh commented 3 years ago

Hi there,

I'm encountering a KeyError where it looks like translator.detect() is returning 'rw' as the language of my text but then that's not a valid key in LANGUAGES.

The text that it is failing on is: "[image: Inline image 1]\n\n2017-06-25 0:47 GMT-04:00 Mariana Matranga :"

This is the error message:

` KeyError Traceback (most recent call last)

in ----> 1 lang, translation = lang_detect(newbody) in lang_detect(text) 3 translation = '' 4 ----> 5 lang = translator.detect(text)[0] 6 7 if lang != 'en': ~\Anaconda3\lib\site-packages\google_trans_new\google_trans_new.py in detect(self, text) 240 raise Exception 241 # data_got = data_got.split('\\\"]')[0] --> 242 return [detect_lang, LANGUAGES[detect_lang.lower()]] 243 r.raise_for_status() 244 except requests.exceptions.HTTPError as e: KeyError: 'rw' `