On 16/04/2021 19:11, Quentin Bock wrote:
is it possible to set the target language of a translation to be the input
from a user?
I have tried inputting specific abbreviations that would normally be
accepted as the target language but it remains in Icelandic and I would
like to change the target language based on the user's input without
creating hundred of scenarios for each inputted language or country.
Thanks

Hi, Quentin!

When you ask a question it is best to give the code you have. For
beginner problems you may even get a hint from people who haven't used
the library in question. That said, I have just installed googletrans,
and changing the destination language appears to be as easy as

>>> import googletrans as gt
>>> t = gt.Translator()
>>> for language in ["de", "fr", "es"]:
...     print(t.translate("Hello, world!", dest=language).text)
...
Hallo Welt!
Bonjour le monde!
¡Hola Mundo!

Does that help?
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to