py-googletrans

(unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally free of charge.

https://github.com/ssut/py-googletrans

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.2%) to scientific vocabulary

Keywords from Contributors

agents observability packaging transformer interactive profiles distribution sequences generic projection
Last synced: 10 months ago · JSON representation

Repository

(unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally free of charge.

Basic Info
Statistics
  • Stars: 4,151
  • Watchers: 72
  • Forks: 739
  • Open Issues: 3
  • Releases: 2
Created about 11 years ago · Last pushed about 1 year ago
Metadata Files
Readme Contributing License

README.rst

Googletrans
===========

|GitHub license| |travis status| |Documentation Status| |PyPI version|
|Coverage Status| |Code Climate|

Googletrans is a **free** and **unlimited** python library that
implemented Google Translate API. This uses the `Google Translate Ajax
API `__ to make calls to such methods as
detect and translate.

Compatible with Python 3.8+.

For details refer to the `API
Documentation `__.

Features
--------

-  Fast and reliable - it uses the same servers that
   translate.google.com uses
-  Auto language detection
-  Bulk translations
-  Customizable service URL
-  Async support
-  HTTP/2 support
-  Proxy support
-  Complete type hints

HTTP/2 support
~~~~~~~~~~~~~~

This library uses httpx for HTTP requests so HTTP/2 is supported by default.

You can check if http2 is enabled and working by the `._response.http_version` of `Translated` or `Detected` object:

.. code:: python

   >>> translator.translate('테스트')._response.http_version
   # 'HTTP/2'


How does this library work
~~~~~~~~~~~~~~~~~~~~~~~~~~

You may wonder why this library works properly, whereas other
approaches such like goslate won't work since Google has updated its
translation service recently with a ticket mechanism to prevent a lot of
crawler programs.

I eventually figure out a way to generate a ticket by reverse
engineering on the `obfuscated and minified code used by Google to
generate such
token `__,
and implemented on the top of Python. However, this could be blocked at
any time.

--------------

Installation
------------

To install, either use things like pip with the package "googletrans"
or download the package and put the "googletrans" directory into your
python path.

.. code:: bash

    $ pip install googletrans

Basic Usage
-----------

If source language is not given, google translate attempts to detect the
source language.

.. code:: python

    >>> import asyncio
    >>> from googletrans import Translator
    >>>
    >>> async def translate_text():
    ...     async with Translator() as translator:
    ...         result = await translator.translate('안녕하세요.')
    ...         print(result)  # 
    ...
    ...         result = await translator.translate('안녕하세요.', dest='ja')
    ...         print(result)  # 
    ...
    ...         result = await translator.translate('veritas lux mea', src='la')
    ...         print(result)  # 
    ...
    >>> asyncio.run(translate_text())

Customize service URL
~~~~~~~~~~~~~~~~~~~~~

You can use another google translate domain for translation. If multiple
URLs are provided, it then randomly chooses a domain.

.. code:: python

    >>> from googletrans import Translator
    >>> translator = Translator(service_urls=[
          'translate.google.com',
          'translate.google.co.kr',
        ])

Customize service URL to point to standard api
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Considering translate.google. url services use the webapp requiring a token,
you can prefer to use the direct api than does not need any token to process.
It can solve your problems of unstable token providing processes (refer to issue #234)

.. code:: python

    >>> from googletrans import Translator
    >>> translator = Translator(service_urls=[
          'translate.googleapis.com'
        ])


Advanced Usage (Bulk)
~~~~~~~~~~~~~~~~~~~~~

Array can be used to translate a batch of strings in a single method
call and a single HTTP session. The exact same method shown above works
for arrays as well.

.. code:: python

    >>> async def translate_bulk():
    ...     async with Translator() as translator:
    ...         translations = await translator.translate(['The quick brown fox', 'jumps over', 'the lazy dog'], dest='ko')
    ...         for translation in translations:
    ...             print(translation.origin, ' -> ', translation.text)
    ...             # The quick brown fox  ->  빠른 갈색 여우
    ...             # jumps over  ->  이상 점프
    ...             # the lazy dog  ->  게으른 개
    ...
    >>> asyncio.run(translate_bulk())

Language detection
~~~~~~~~~~~~~~~~~~

The detect method, as its name implies, identifies the language used in
a given sentence.

.. code:: python

    >>> async def detect_languages():
    ...     async with Translator() as translator:
    ...         result = await translator.detect('이 문장은 한글로 쓰여졌습니다.')
    ...         print(result)  # 
    ...
    ...         result = await translator.detect('この文章は日本語で書かれました。')
    ...         print(result)  # 
    ...
    ...         result = await translator.detect('This sentence is written in English.')
    ...         print(result)  # 
    ...
    ...         result = await translator.detect('Tiu frazo estas skribita en Esperanto.')
    ...         print(result)  # 
    ...
    >>> asyncio.run(detect_languages())

GoogleTrans as a command line application
-----------------------------------------

.. code:: bash

    $ translate -h
    usage: translate [-h] [-d DEST] [-s SRC] [-c] text

    Python Google Translator as a command-line tool

    positional arguments:
      text                  The text you want to translate.

    optional arguments:
      -h, --help            show this help message and exit
      -d DEST, --dest DEST  The destination language you want to translate.
                            (Default: en)
      -s SRC, --src SRC     The source language you want to translate. (Default:
                            auto)
      -c, --detect

    $ translate "veritas lux mea" -s la -d en
    [veritas] veritas lux mea
        ->
    [en] The truth is my light
    [pron.] The truth is my light

    $ translate -c "안녕하세요."
    [ko, 1] 안녕하세요.

--------------

Note on library usage
---------------------

DISCLAIMER: this is an unofficial library using the web API of translate.google.com
and also is not associated with Google.

-  **The maximum character limit on a single text is 15k.**

-  Due to limitations of the web version of google translate, this API
   does not guarantee that the library would work properly at all times
   (so please use this library if you don't care about stability).

-  **Important:** If you want to use a stable API, I highly recommend you to use
   `Google's official translate
   API `__.

-  If you get HTTP 5xx error or errors like #6, it's probably because
   Google has banned your client IP address.

--------------

Versioning
----------

This library follows `Semantic Versioning `__ from
v2.0.0. Any release versioned 0.x.y is subject to backwards incompatible
changes at any time.

Contributing
-------------------------

Contributions are more than welcomed. See
`CONTRIBUTING.md `__

-----------------------------------------

License
-------

Googletrans is licensed under the MIT License. The terms are as
follows:

::

    The MIT License (MIT)

    Copyright (c) 2015 SuHun Han

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

.. |GitHub license| image:: https://img.shields.io/github/license/mashape/apistatus.svg
   :target: http://opensource.org/licenses/MIT
.. |travis status| image:: https://github.com/ssut/py-googletrans/actions/workflows/ci.yml/badge.svg
   :target: https://github.com/ssut/py-googletrans/actions/workflows/ci.yml
.. |Documentation Status| image:: https://readthedocs.org/projects/py-googletrans/badge/?version=latest
   :target: https://readthedocs.org/projects/py-googletrans/?badge=latest
.. |PyPI version| image:: https://badge.fury.io/py/googletrans.svg
   :target: http://badge.fury.io/py/googletrans
.. |Coverage Status| image:: https://coveralls.io/repos/github/ssut/py-googletrans/badge.svg
   :target: https://coveralls.io/github/ssut/py-googletrans
.. |Code Climate| image:: https://codeclimate.com/github/ssut/py-googletrans/badges/gpa.svg
   :target: https://codeclimate.com/github/ssut/py-googletrans

Owner

  • Name: Suhun Han
  • Login: ssut
  • Kind: user
  • Location: Seoul, Republic of Korea
  • Company: @brandazine

@brandazine Lead Software Engineer. TypeScript and Go enthusiast.

GitHub Events

Total
  • Create event: 4
  • Commit comment event: 2
  • Release event: 1
  • Issues event: 61
  • Watch event: 267
  • Delete event: 3
  • Issue comment event: 72
  • Push event: 21
  • Pull request event: 24
  • Fork event: 37
Last Year
  • Create event: 4
  • Commit comment event: 2
  • Release event: 1
  • Issues event: 61
  • Watch event: 267
  • Delete event: 3
  • Issue comment event: 72
  • Push event: 21
  • Pull request event: 24
  • Fork event: 37

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 129
  • Total Committers: 31
  • Avg Commits per committer: 4.161
  • Development Distribution Score (DDS): 0.372
Past Year
  • Commits: 15
  • Committers: 7
  • Avg Commits per committer: 2.143
  • Development Distribution Score (DDS): 0.4
Top Committers
Name Email Commits
ssut s****t@s****e 81
Terry Zhuo t****5@g****m 15
Encrylize E****e 4
Mateusz Susik m****k@g****m 2
Mariusz Korzekwa m****a@d****l 1
Jose Antonio Morales Ponce j****e@v****m 1
Nieole s****d@g****m 1
Martin Michlmayr t****m@c****m 1
Jakub Molinski k****i@g****m 1
ButterflyOfFire 4****e 1
Bastien Vallet b****t@g****m 1
Artur Aleksanyan a****9@g****m 1
Arslan Rejepov 9****3 1
Abduroid 5****d 1
yupengzhang u****c@g****m 1
paulg c****8@g****m 1
garden.yuen w****g 1
elzeard91 4****1 1
dependabot[bot] 4****] 1
crypticGøøse c****n@g****m 1
clinjie 6****5@q****m 1
adipose 3****e 1
Xiao Meifeng x****t@g****m 1
Xdynix L****r@g****m 1
Walter Purcaro v****r 1
Stephan Akkerman 4****n 1
Soumendra kumar sahoo s****s@o****m 1
Sin-Woo Bang s****g@g****m 1
Sebastian Stabinger s****n@s****e 1
Sarah Fletcher R****r 1
and 1 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 131
  • Total pull requests: 46
  • Average time to close issues: 7 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 122
  • Total pull request authors: 32
  • Average comments per issue: 7.09
  • Average comments per pull request: 0.89
  • Merged pull requests: 10
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 19
  • Pull requests: 20
  • Average time to close issues: 2 months
  • Average time to close pull requests: 10 days
  • Issue authors: 18
  • Pull request authors: 13
  • Average comments per issue: 1.21
  • Average comments per pull request: 0.35
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 2
Top Authors
Issue Authors
  • xLinkOut (3)
  • SwedishBarbarossa (2)
  • choppeh (2)
  • Jami1141 (2)
  • DanilKonon (2)
  • me-suzy (2)
  • Alessandro-Barbieri (2)
  • terryyz (2)
  • lixnvege (1)
  • Johnthen1 (1)
  • ssut (1)
  • TheLostProgrammer (1)
  • bai-yi-bai (1)
  • juncaofish (1)
  • Dnyana (1)
Pull Request Authors
  • bllendev (9)
  • c-goosen (6)
  • GoRaN909 (2)
  • Siddhesh-Agarwal (2)
  • BoFFire (2)
  • AxesAccess (2)
  • dependabot[bot] (2)
  • fcoagz (2)
  • massifsurfer (2)
  • StephanAkkerman (2)
  • UnBonWhisky (2)
  • Xdynix (2)
  • Abemelekermi (2)
  • raf-sh (2)
  • leen2233 (2)
Top Labels
Issue Labels
wontfix (70) resolved in 4.0.0 (24) bug (6) in progress (4) pinned (4) enhancement (2)
Pull Request Labels
wontfix (9) dependencies (2) python (2)

Packages

  • Total packages: 8
  • Total downloads:
    • pypi 543,000 last-month
  • Total docker downloads: 65,898
  • Total dependent packages: 106
    (may contain duplicates)
  • Total dependent repositories: 4,777
    (may contain duplicates)
  • Total versions: 31
  • Total maintainers: 5
pypi.org: googletrans

An unofficial Google Translate API for Python

  • Versions: 14
  • Dependent Packages: 105
  • Dependent Repositories: 4,770
  • Downloads: 542,445 Last month
  • Docker Downloads: 65,898
Rankings
Dependent repos count: 0.1%
Dependent packages count: 0.2%
Downloads: 0.5%
Average: 0.8%
Docker downloads count: 1.0%
Stargazers count: 1.3%
Forks count: 1.7%
Maintainers (1)
Last synced: 10 months ago
proxy.golang.org: github.com/ssut/py-googletrans
  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 10 months ago
pypi.org: py-googletrans

An unofficial Google Translate API for Python

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 4
  • Downloads: 342 Last month
Rankings
Stargazers count: 1.3%
Forks count: 1.6%
Dependent repos count: 7.5%
Average: 9.1%
Dependent packages count: 10.1%
Downloads: 24.9%
Maintainers (1)
Last synced: 10 months ago
pypi.org: googletrans-temp

Free Google Translate API for Python. Translates totally free of charge.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 159 Last month
Rankings
Stargazers count: 1.3%
Forks count: 1.6%
Dependent packages count: 10.1%
Average: 11.0%
Downloads: 20.6%
Dependent repos count: 21.5%
Maintainers (1)
Last synced: 10 months ago
conda-forge.org: googletrans

Googletrans is a free and unlimited python library that implemented Google Translate API. This uses the Google Translate Ajax API to make calls to such methods as detect and translate. Compatible with Python 2.7+ and 3.4+. (Note: Python 2 support will be dropped in the next major release.)

  • Versions: 2
  • Dependent Packages: 1
  • Dependent Repositories: 2
Rankings
Forks count: 6.4%
Stargazers count: 7.0%
Average: 15.7%
Dependent repos count: 20.3%
Dependent packages count: 29.0%
Last synced: 10 months ago
pypi.org: googletrans-di

Free Google Translate API for Python. Translates totally free of charge.

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 40 Last month
Rankings
Dependent packages count: 10.0%
Average: 33.1%
Dependent repos count: 56.3%
Maintainers (1)
Last synced: 10 months ago
pypi.org: modifiedgoogletrans

Free Google Translate API for Python. Translates totally free of charge.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 10.2%
Average: 33.6%
Dependent repos count: 57.1%
Maintainers (1)
Last synced: over 1 year ago
pypi.org: googletrans-wheel

Free Google Translate API for Python. Translates totally free of charge.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 14 Last month
Rankings
Dependent packages count: 10.7%
Average: 35.5%
Dependent repos count: 60.4%
Maintainers (1)
Last synced: 10 months ago

Dependencies

Pipfile pypi
  • coveralls * develop
  • pytest-testmon * develop
  • pytest-watch * develop
  • sphinx * develop
  • httpx ==0.14.1
Pipfile.lock pypi
  • alabaster ==0.7.12 develop
  • attrs ==20.1.0 develop
  • babel ==2.8.0 develop
  • certifi ==2020.6.20 develop
  • chardet ==3.0.4 develop
  • colorama ==0.4.3 develop
  • coverage ==5.2.1 develop
  • coveralls ==2.1.2 develop
  • docopt ==0.6.2 develop
  • docutils ==0.16 develop
  • idna ==2.10 develop
  • imagesize ==1.2.0 develop
  • importlib-metadata ==1.7.0 develop
  • iniconfig ==1.0.1 develop
  • jinja2 ==2.11.2 develop
  • markupsafe ==1.1.1 develop
  • more-itertools ==8.5.0 develop
  • packaging ==20.4 develop
  • pathtools ==0.1.2 develop
  • pluggy ==0.13.1 develop
  • py ==1.9.0 develop
  • pygments ==2.6.1 develop
  • pyparsing ==2.4.7 develop
  • pytest ==6.0.1 develop
  • pytest-testmon ==1.0.3 develop
  • pytest-watch ==4.2.0 develop
  • pytz ==2020.1 develop
  • requests ==2.24.0 develop
  • six ==1.15.0 develop
  • snowballstemmer ==2.0.0 develop
  • sphinx ==3.2.1 develop
  • sphinxcontrib-applehelp ==1.0.2 develop
  • sphinxcontrib-devhelp ==1.0.2 develop
  • sphinxcontrib-htmlhelp ==1.0.3 develop
  • sphinxcontrib-jsmath ==1.0.1 develop
  • sphinxcontrib-qthelp ==1.0.3 develop
  • sphinxcontrib-serializinghtml ==1.1.4 develop
  • toml ==0.10.1 develop
  • urllib3 ==1.25.10 develop
  • watchdog ==0.10.3 develop
  • zipp ==3.1.0 develop
  • certifi ==2020.6.20
  • chardet ==3.0.4
  • h11 ==0.9.0
  • httpcore ==0.10.2
  • httpx ==0.14.1
  • idna ==2.10
  • rfc3986 ==1.4.0
  • sniffio ==1.1.0
setup.py pypi
  • httpx ==0.13.3
test-requirements.txt pypi
  • coveralls ==1.1 test