translate (Unofficial API Client)
The `translate` library (by terryyin) is a simple command-line and Python module translator. It aims to provide translations using services like Google Translate, but operates as an unofficial client. The current version, 3.8.0, was last released on November 2, 2025, and maintains an active, albeit infrequent, release schedule.
Warnings
- breaking This library is an *unofficial* client for web translation services (including Google Translate's web interface). It does not use an official API key and is therefore susceptible to breaking changes if the underlying web services modify their structure or anti-bot measures. Stability is not guaranteed.
- gotcha The default translation provider for the `translate` library (as of v3.3.0 and onwards) is MyMemory, which imposes free usage limits (e.g., 1000 words/day). Exceeding this limit will result in errors. While the library can be configured to use other providers (e.g., Google, Microsoft, DeepL), these may require explicit configuration and potentially a `secret_access_key`.
- gotcha Frequent or high-volume requests, especially when using providers that wrap public web interfaces, can lead to aggressive rate limiting, temporary IP bans (resulting in HTTP 5xx errors), or CAPTCHA challenges.
- gotcha Translations obtained through unofficial web-scraping methods, as used by this library, may lack the accuracy, nuance, and context-awareness provided by official, paid APIs. This can lead to less reliable or contextually incorrect results, particularly for complex, technical, or sensitive texts.
Install
-
pip install translate
Imports
- Translator
from translate import Translator
Quickstart
from translate import Translator
# Initialize translator, specifying the target language
# The default provider is MyMemory, which has free usage limits.
# For other providers like Google, Microsoft, or DeepL, specify them
# along with a 'secret_access_key' if required (see warnings).
translator = Translator(to_lang="fr")
text_to_translate = "Hello, world!"
try:
translation = translator.translate(text_to_translate)
print(f"Original: {text_to_translate}")
print(f"Translated (French): {translation}")
except Exception as e:
print(f"An error occurred during translation: {e}")
print("Note: The default provider (MyMemory) has free usage limits. You might have exceeded them.")