How can I use google translation API in Django with python

4k Views Asked by At

I am using Django to create a project where I can change the language of website where user can use the page in any language they are comfortable with. But I am not sure how to implement google translate API in Django can anyone help me. I know that we can install google translation API using

"$ pip install googletrans"

but how can we implement this in Django framework. I am new to python. Thank you in advance.

2

There are 2 best solutions below

0
On

there is a pip package which you can import in your templates and there will be google translate button. django-google-translate visit this and you will find more information.

0
On

you can use googletrans library. Here I include the library. https://pypi.org/project/googletrans/ Here the documentation also availabe. It is easy to use.

pip install googletrans

    from googletrans import Translator

    translator = Translator()
    data = await translator.translate('යුනිකෝඩ් ', dest='ec', src='si').text()