googletrans-fixed: the unofficial Google Translate client, kept working
A Python library that calls Google Translate's web service for detect and translate, with auto language detection, bulk translation, a configurable service U…
On this page
googletrans-fixed: the unofficial Google Translate client, kept working
TL;DR
googletrans-fixedis a Python library that speaks to Google Translate's web service, so it is free and unlimited by design — it calls the same serverstranslate.google.comcalls.- Four features do the work: auto language detection, bulk translation, a customizable service URL, and HTTP/2 through
httpx. - The library's trick is a ticket: Google added a token mechanism to stop crawler programs, and the library generates that ticket from the reverse-engineered client code, which the README says could be blocked at any time.
- Honest note on the name: the README here is the upstream library's documentation, and the
-fixedin the repository name is the repository's own claim rather than something the documentation proves.
What it is and who it is for
googletrans-fixed is a Python translation library, compatible with Python 3.6 and later. It implements the methods detect and translate against Google Translate's Ajax API, and its own documentation is the upstream Googletrans documentation — which is why this article distinguishes what the README states from what the repository name claims.
It is for the person who needs to translate a batch of strings in a script and does not want to pay for a translation API, and for the one whose installed googletrans broke and who found three copies of the package on PyPI with different dates.
The features
- Fast and reliable, by inheritance. It uses the same servers that
translate.google.comuses, which is the source of both the speed and the fragility. - Auto language detection. If the source language is not given, the library asks Google to detect it.
- Bulk translations. A list of strings goes in one call rather than one request per string.
- Customizable service URL. The service endpoint can be pointed elsewhere, which matters behind a proxy or a regional mirror.
- HTTP/2 support. Requests go through
httpx, so HTTP/2 works by default, and the README shows checking it through the._response.http_versionof aTranslatedorDetectedobject.
Why it needs a ticket
The README's explanation is the interesting part. Other approaches such as goslate stopped working because Google updated its translation service with a ticket mechanism to prevent crawler programs. The library generates that ticket by reverse engineering the obfuscated and minified JavaScript Google uses for it, and implements the result in Python.
The honest consequence is stated in the same paragraph: this could be blocked at any time. A translation library built on a reverse-engineered token is a library with a dependency on a page nobody promised to keep stable — which is exactly why patched copies exist.
Install and usage
pip install googletrans
The README also accepts downloading the package and putting the googletrans directory on your Python path. Basic usage is one translator object, one translate call, and a Detected or Translated result; when the source language is omitted, detection happens first.
When to use it, when not to
Use it when you need free translation of a batch of strings inside a script, when a paid API is overkill, or when you want a dependency-free install for a small tool.
Do not use it for anything with a service-level expectation: the README's own limits apply — a ticket that can be blocked at any time, a missing proxy support listed as a to-do, and session management for bulk translation also listed as a to-do. Do not use it for a legal or contractual translation either; this is the same web endpoint a browser uses, with no guarantee behind it.
Sources
- googletrans-fixed — repository — the repository publishes the library with the upstream Googletrans documentation in
README.rst. - README.rst — features, HTTP/2 note, the ticket explanation, installation, usage, to-do list.
Project page: googletrans-fixed
FAQ
How does it work without an API key? It calls Google Translate's Ajax API, the same servers translate.google.com uses, generating the ticket that Google's client code produces.
Does it support HTTP/2? Yes. Requests go through httpx, so HTTP/2 works by default, and the README shows checking it on a response object.
Does it detect the source language? Yes. If the source language is not given, the library asks Google to detect it.
What are the known limits? The README lists proxy support and internal session management for bulk translation as to-dos, and warns that the reverse-engineered ticket could be blocked at any time.