Open Ben-Bock opened 3 years ago
Sometimes the translator returns a list sometimes just a text. Steps to reproduce:
from google_trans_new import google_translator translator = google_translator()
from google_trans_new import google_translator
translator = google_translator()
print (translator.translate('ALL', lang_tgt='fr')) produces: ['TOUT', 'TOUTE']
print (translator.translate('ALL', lang_tgt='fr'))
while: print (translator.translate('In Progress', lang_tgt='fr')) produces: "En cours"
print (translator.translate('In Progress', lang_tgt='fr'))
Is there a way for more consistend handling (e.g. by default allways return 1st and have alternative translations only on demand)?
Thx & best regards,
Ben
I fixed it now for my purpose like this:
def clean(_translation): if(type(_translation)==list): return _translation[0] else: return _translation
Maybe something like that could become a common feture?
Sometimes the translator returns a list sometimes just a text. Steps to reproduce:
from google_trans_new import google_translator
translator = google_translator()
print (translator.translate('ALL', lang_tgt='fr'))
produces: ['TOUT', 'TOUTE']while:
print (translator.translate('In Progress', lang_tgt='fr'))
produces: "En cours"Is there a way for more consistend handling (e.g. by default allways return 1st and have alternative translations only on demand)?
Thx & best regards,
Ben