{"id":13411823,"url":"https://github.com/ssut/py-googletrans","last_synced_at":"2025-05-14T08:05:16.428Z","repository":{"id":33277070,"uuid":"36921680","full_name":"ssut/py-googletrans","owner":"ssut","description":"(unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally free of charge.","archived":false,"fork":false,"pushed_at":"2025-04-25T00:44:31.000Z","size":643,"stargazers_count":4097,"open_issues_count":6,"forks_count":740,"subscribers_count":72,"default_branch":"main","last_synced_at":"2025-05-14T08:04:23.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://py-googletrans.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssut.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-06-05T08:35:11.000Z","updated_at":"2025-05-14T02:40:48.000Z","dependencies_parsed_at":"2023-01-16T22:45:29.781Z","dependency_job_id":"227776b9-ca44-4477-9906-c3f58b365fca","html_url":"https://github.com/ssut/py-googletrans","commit_stats":{"total_commits":122,"total_committers":29,"mean_commits":4.206896551724138,"dds":0.3770491803278688,"last_synced_commit":"52229c2bbc717c034a8b8327943919856faabddd"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Fpy-googletrans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Fpy-googletrans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Fpy-googletrans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssut%2Fpy-googletrans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssut","download_url":"https://codeload.github.com/ssut/py-googletrans/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:17.269Z","updated_at":"2025-05-14T08:05:16.407Z","avatar_url":"https://github.com/ssut.png","language":"Python","funding_links":[],"categories":["Python","Data Processing","其他_NLP自然语言处理","Third-party Web APIs"],"sub_categories":["Data Pre-processing \u0026 Loading","其他_文本生成、文本对话"],"readme":"Googletrans\n===========\n\n|GitHub license| |travis status| |Documentation Status| |PyPI version|\n|Coverage Status| |Code Climate|\n\nGoogletrans is a **free** and **unlimited** python library that\nimplemented Google Translate API. This uses the `Google Translate Ajax\nAPI \u003chttps://translate.google.com\u003e`__ to make calls to such methods as\ndetect and translate.\n\nCompatible with Python 3.8+.\n\nFor details refer to the `API\nDocumentation \u003chttps://py-googletrans.readthedocs.io/en/latest\u003e`__.\n\nFeatures\n--------\n\n-  Fast and reliable - it uses the same servers that\n   translate.google.com uses\n-  Auto language detection\n-  Bulk translations\n-  Customizable service URL\n-  Async support\n-  HTTP/2 support\n-  Proxy support\n-  Complete type hints\n\nHTTP/2 support\n~~~~~~~~~~~~~~\n\nThis library uses httpx for HTTP requests so HTTP/2 is supported by default.\n\nYou can check if http2 is enabled and working by the `._response.http_version` of `Translated` or `Detected` object:\n\n.. code:: python\n\n   \u003e\u003e\u003e translator.translate('테스트')._response.http_version\n   # 'HTTP/2'\n\n\nHow does this library work\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou may wonder why this library works properly, whereas other\napproaches such like goslate won't work since Google has updated its\ntranslation service recently with a ticket mechanism to prevent a lot of\ncrawler programs.\n\nI eventually figure out a way to generate a ticket by reverse\nengineering on the `obfuscated and minified code used by Google to\ngenerate such\ntoken \u003chttps://translate.google.com/translate/releases/twsfe_w_20170306_RC00/r/js/desktop_module_main.js\u003e`__,\nand implemented on the top of Python. However, this could be blocked at\nany time.\n\n--------------\n\nInstallation\n------------\n\nTo install, either use things like pip with the package \"googletrans\"\nor download the package and put the \"googletrans\" directory into your\npython path.\n\n.. code:: bash\n\n    $ pip install googletrans\n\nBasic Usage\n-----------\n\nIf source language is not given, google translate attempts to detect the\nsource language.\n\n.. code:: python\n\n    \u003e\u003e\u003e import asyncio\n    \u003e\u003e\u003e from googletrans import Translator\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e async def translate_text():\n    ...     async with Translator() as translator:\n    ...         result = await translator.translate('안녕하세요.')\n    ...         print(result)  # \u003cTranslated src=ko dest=en text=Good evening. pronunciation=Good evening.\u003e\n    ...\n    ...         result = await translator.translate('안녕하세요.', dest='ja')\n    ...         print(result)  # \u003cTranslated src=ko dest=ja text=こんにちは。 pronunciation=Kon'nichiwa.\u003e\n    ...\n    ...         result = await translator.translate('veritas lux mea', src='la')\n    ...         print(result)  # \u003cTranslated src=la dest=en text=The truth is my light pronunciation=The truth is my light\u003e\n    ...\n    \u003e\u003e\u003e asyncio.run(translate_text())\n\nCustomize service URL\n~~~~~~~~~~~~~~~~~~~~~\n\nYou can use another google translate domain for translation. If multiple\nURLs are provided, it then randomly chooses a domain.\n\n.. code:: python\n\n    \u003e\u003e\u003e from googletrans import Translator\n    \u003e\u003e\u003e translator = Translator(service_urls=[\n          'translate.google.com',\n          'translate.google.co.kr',\n        ])\n\nCustomize service URL to point to standard api\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nConsidering translate.google.\u003cdomain\u003e url services use the webapp requiring a token,\nyou can prefer to use the direct api than does not need any token to process.\nIt can solve your problems of unstable token providing processes (refer to issue #234)\n\n.. code:: python\n\n    \u003e\u003e\u003e from googletrans import Translator\n    \u003e\u003e\u003e translator = Translator(service_urls=[\n          'translate.googleapis.com'\n        ])\n\n\nAdvanced Usage (Bulk)\n~~~~~~~~~~~~~~~~~~~~~\n\nArray can be used to translate a batch of strings in a single method\ncall and a single HTTP session. The exact same method shown above works\nfor arrays as well.\n\n.. code:: python\n\n    \u003e\u003e\u003e async def translate_bulk():\n    ...     async with Translator() as translator:\n    ...         translations = await translator.translate(['The quick brown fox', 'jumps over', 'the lazy dog'], dest='ko')\n    ...         for translation in translations:\n    ...             print(translation.origin, ' -\u003e ', translation.text)\n    ...             # The quick brown fox  -\u003e  빠른 갈색 여우\n    ...             # jumps over  -\u003e  이상 점프\n    ...             # the lazy dog  -\u003e  게으른 개\n    ...\n    \u003e\u003e\u003e asyncio.run(translate_bulk())\n\nLanguage detection\n~~~~~~~~~~~~~~~~~~\n\nThe detect method, as its name implies, identifies the language used in\na given sentence.\n\n.. code:: python\n\n    \u003e\u003e\u003e async def detect_languages():\n    ...     async with Translator() as translator:\n    ...         result = await translator.detect('이 문장은 한글로 쓰여졌습니다.')\n    ...         print(result)  # \u003cDetected lang=ko confidence=0.27041003\u003e\n    ...\n    ...         result = await translator.detect('この文章は日本語で書かれました。')\n    ...         print(result)  # \u003cDetected lang=ja confidence=0.64889508\u003e\n    ...\n    ...         result = await translator.detect('This sentence is written in English.')\n    ...         print(result)  # \u003cDetected lang=en confidence=0.22348526\u003e\n    ...\n    ...         result = await translator.detect('Tiu frazo estas skribita en Esperanto.')\n    ...         print(result)  # \u003cDetected lang=eo confidence=0.10538048\u003e\n    ...\n    \u003e\u003e\u003e asyncio.run(detect_languages())\n\nGoogleTrans as a command line application\n-----------------------------------------\n\n.. code:: bash\n\n    $ translate -h\n    usage: translate [-h] [-d DEST] [-s SRC] [-c] text\n\n    Python Google Translator as a command-line tool\n\n    positional arguments:\n      text                  The text you want to translate.\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -d DEST, --dest DEST  The destination language you want to translate.\n                            (Default: en)\n      -s SRC, --src SRC     The source language you want to translate. (Default:\n                            auto)\n      -c, --detect\n\n    $ translate \"veritas lux mea\" -s la -d en\n    [veritas] veritas lux mea\n        -\u003e\n    [en] The truth is my light\n    [pron.] The truth is my light\n\n    $ translate -c \"안녕하세요.\"\n    [ko, 1] 안녕하세요.\n\n--------------\n\nNote on library usage\n---------------------\n\nDISCLAIMER: this is an unofficial library using the web API of translate.google.com\nand also is not associated with Google.\n\n-  **The maximum character limit on a single text is 15k.**\n\n-  Due to limitations of the web version of google translate, this API\n   does not guarantee that the library would work properly at all times\n   (so please use this library if you don't care about stability).\n\n-  **Important:** If you want to use a stable API, I highly recommend you to use\n   `Google's official translate\n   API \u003chttps://cloud.google.com/translate/docs\u003e`__.\n\n-  If you get HTTP 5xx error or errors like #6, it's probably because\n   Google has banned your client IP address.\n\n--------------\n\nVersioning\n----------\n\nThis library follows `Semantic Versioning \u003chttp://semver.org/\u003e`__ from\nv2.0.0. Any release versioned 0.x.y is subject to backwards incompatible\nchanges at any time.\n\nContributing\n-------------------------\n\nContributions are more than welcomed. See\n`CONTRIBUTING.md \u003cCONTRIBUTING.md\u003e`__\n\n-----------------------------------------\n\nLicense\n-------\n\nGoogletrans is licensed under the MIT License. The terms are as\nfollows:\n\n::\n\n    The MIT License (MIT)\n\n    Copyright (c) 2015 SuHun Han\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n\n.. |GitHub license| image:: https://img.shields.io/github/license/mashape/apistatus.svg\n   :target: http://opensource.org/licenses/MIT\n.. |travis status| image:: https://github.com/ssut/py-googletrans/actions/workflows/ci.yml/badge.svg\n   :target: https://github.com/ssut/py-googletrans/actions/workflows/ci.yml\n.. |Documentation Status| image:: https://readthedocs.org/projects/py-googletrans/badge/?version=latest\n   :target: https://readthedocs.org/projects/py-googletrans/?badge=latest\n.. |PyPI version| image:: https://badge.fury.io/py/googletrans.svg\n   :target: http://badge.fury.io/py/googletrans\n.. |Coverage Status| image:: https://coveralls.io/repos/github/ssut/py-googletrans/badge.svg\n   :target: https://coveralls.io/github/ssut/py-googletrans\n.. |Code Climate| image:: https://codeclimate.com/github/ssut/py-googletrans/badges/gpa.svg\n   :target: https://codeclimate.com/github/ssut/py-googletrans\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssut%2Fpy-googletrans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssut%2Fpy-googletrans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssut%2Fpy-googletrans/lists"}