An async-first Python library for translating text using the Google Translate API. Currently at version 2.1.0, it requires Python >=3.12 and uses aiohttp for async HTTP requests. The library provides both async (Translator) and sync (SyncTranslator) interfaces, along with language detection and text-to-speech (TTS) support. Releases are sporadic, with the last major update in 2025.
pip install gpytranslateVerified import paths — ran on the pinned version, not inferred.
Basic async translation example using Translator as an async context manager.
Upgrade to Python 3.12+ or pin to gpytranslate==1.5.1 if you need older Python.
Wrap usage in `async with Translator() as t:` or explicitly call `await t.close()` when done.
Catch `gpytranslate.TranslateError` specifically and implement retry logic with exponential backoff.
Use: `t = SyncTranslator(); result = t.translate(...)`
Replace `translator.__version__` with `from gpytranslate import __version__`
Reinstall: `pip install --upgrade gpytranslate`. Verify import in a fresh Python session.
Add delays between requests or use a proxy rotation. Reduce request frequency.
Use `await` directly in async context or use `asyncio.run()` only from sync entry points.