
How to Upgrade Python Googletrans to Google Translate Enterprise API Upgrading to Google Translate Enterprise is fairly simple. It only involves modifying the initialization of the translator and changing the translate command. This looks like the following:
# app/templatetags/app_filters.py
from google.cloud import translate_v2 as translate
...
# translator = translate.Translator() -- Remove this
translator = translate.Client.from_service_account_json('/home/path/to/service-account-file.json') # Change to this
...
# app/templatetags/app_filters.py
...
# translation = translator.translate(...) -- Remove this
translation = translator.translate(value, target_language=lang, source_language='en', format_='html')['translatedText'] # Change to this
...
one comment.
Comments (1) Comment

Uglek is now mostly translated, save for a few views. It is also much faster with this translation API.
© Uglek, 2022