Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deal with multiple returned translations? How to get 1st. translatin only? #44

Open
Ben-Bock opened this issue Jul 28, 2021 · 1 comment

Comments

@Ben-Bock
Copy link

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

@Ben-Bock
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant