I don't know if you've solved your issue but I experienced the same thing. I discovered the module google_trans_new. You should try it:
pip install google_trans_new
For the translation part:
from google_trans_new import google_translator
translator = google_translator()
translate_text = translator.translate('首先感谢我的父母他们对我的关爱',lang_tgt='en')
which return:
'First of all thank my parents for their love'
For detection:
from google_trans_new import google_translator
detector = google_translator()
detect_result = detector.detect('首先感谢我的父母他们对我的关爱')
which gives
['zh-CN', 'chinese (simplified)']
In your case, it would maybe work this way:
detector = google_translator()
def detect(x):
try:
detected_language = detector.detect(x)
except:
detected_language = None
return detected_language
df['language detected'] = df2['text_pl'].apply(detect)
to detect the language (if your not sure all is in english or polish).
And in a similar way to translate. (See example above). I did this way:
Translationlist = df2['text_pl'].unique()
LANGT = []
for lang in Translationlist :
try:
translate_text = translator.translate(lang, lang_tgt='en')
except:
translate_text = None
LANGT.append(translate_text)
and then merged it with the original dataframe. (Reason of choice: 40 languages and some "weird" text I wasn't sure would be translatable), but you may not need to do it that way.