translate


Nametranslate JSON
Version 3.6.1 PyPI version JSON
download
home_pagehttps://github.com/terryyin/google-translate-python
SummaryThis is a simple, yet powerful command line translator with google translate behind it. You can also use it as a Python module in your code.
upload_time2021-07-06 03:27:19
maintainer
docs_urlNone
authorTerry Yin
requires_python
licenseMIT
keywords translate translation command line
VCS
bugtrack_url
requirements click lxml requests libretranslatepy
Travis-CI
coveralls test coverage
            
========================
Translate Tool in Python
========================

|PyPI latest| |PyPI Version| |PyPI License| |Docs| |Travis Build Status|


Translate is a simple but powerful translation tool written in python with with support for
multiple translation providers. By now we offer integration with Microsoft Translation API,
Translated MyMemory API, LibreTranslate, and DeepL's free and pro APIs


Why Should I Use This?
----------------------

The biggest reason to use translate is to  make translations in a simple way without the need of bigger
effort and can be used as a translation tool like command line



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

.. code-block:: bash

   $ pip install translate

Or, you can download the source and

.. code-block:: bash

   $ python setup.py install

Prefix 'sudo' if you encounter a problem.


Features
--------

- Translate your output in real time
- Do translation in your terminal using the command line

Usage
-----

In your command-line:

.. code-block:: bash

   $ translate-cli -t zh "This is a pen."

   Translation: 这是一支笔
   -------------------------
   Translated by: MyMemory

Or

.. code-block:: bash

   $ translate-cli -t zh "This is a pen." -o
   这是一支笔

Options
~~~~~~~

.. code-block:: bash

    $ translate-cli --help
    Usage: __main__.py [OPTIONS] TEXT...

      Python command line tool to make online translations

      Example:

           $ translate-cli -t zh the book is on the table
           碗是在桌子上。

      Available languages:

           https://en.wikipedia.org/wiki/ISO_639-1
           Examples: (e.g. en, ja, ko, pt, zh, zh-TW, ...)

    Options:
      --version                 Show the version and exit.
      --generate-config-file    Generate the config file using a Wizard and exit.
      -f, --from TEXT           Sets the language of the text being translated.
                                The default value is 'autodetect'.
      -t, --to TEXT             Set the language you want to translate.
      -p, --provider TEXT       Set the provider you want to use. The default
                                value is 'mymemory'.
      --secret_access_key TEXT  Set the secret access key used to get provider
                                oAuth token.
      -o, --output_only         Set to display the translation only.
      --help                    Show this message and exit.


Change Default Languages
~~~~~~~~~~~~~~~~~~~~~~~~

In ~/.python-translate.cfg:

.. code-block:: bash

   [DEFAULT]
   from_lang = autodetect
   to_lang = de
   provider = mymemory
   secret_access_key =

The cfg is not for use as a Python module.

or run the command line and follow the steps:

.. code-block:: bash

    $ translate-cli --generate-config-file
    Translate from [autodetect]:
    Translate to: <language you want to translate>
    Provider [mymemory]:
    Secret Access Key []:


Use As A Python Module
----------------------

.. code-block:: python

   In [1]: from translate import Translator
   In [2]: translator= Translator(to_lang="zh")
   In [3]: translation = translator.translate("This is a pen.")
   Out [3]: 这是一支笔

The result is usually a unicode string.


Use a different translation provider
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    In [1]: from translate import Translator
    In [2]: to_lang = 'zh'
    In [3]: secret = '<your secret from Microsoft or DeepL>'
    In [4]: translator = Translator(provider='<the name of the provider, eg. microsoft or deepl>', to_lang=to_lang, secret_access_key=secret)
    In [5]: translator.translate('the book is on the table')
    Out [5]: '碗是在桌子上。'

The DeepL Provider
~~~~~~~~~~~~~~~~~~
To use DeepL's pro API, pass an additional parameter called pro to the Translator object and set it to True and use your pro authentication key as the secret_access_key

.. code-block:: python

    In: translator = Translator(provider='microsoft', to_lang=to_lang, secret_access_key=secret, pro=True)

Documentation
-------------

Check out the latest ``translate`` documentation at `Read the Docs <http://translate-python.readthedocs.io/en/latest/>`_


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

Please send pull requests, very much appreciated.


1. Fork the `repository <https://github.com/terryyin/translate-python>`_ on GitHub.
2. Make a branch off of master and commit your changes to it.
3. Install requirements. ``pip install -r requirements-dev.txt``
4. Install pre-commit. ``pre-commit install``
5. Run the tests with ``py.test -vv -s``
6. Create a Pull Request with your contribution



.. |Docs| image:: https://readthedocs.org/projects/translate-python/badge/?version=latest
   :target: http://translate-python.readthedocs.org/en/latest/?badge=latest
.. |Travis Build Status| image:: https://api.travis-ci.org/terryyin/translate-python.png?branch=master
   :target: https://travis-ci.org/terryyin/translate-python
.. |PyPI Version| image:: https://img.shields.io/pypi/pyversions/translate.svg?maxAge=2592000
   :target: https://pypi.python.org/pypi/translate
.. |PyPI License| image:: https://img.shields.io/pypi/l/translate.svg?maxAge=2592000
   :target: https://github.com/terryyin/translate-python/blob/master/LICENSE
.. |PyPI latest| image:: https://img.shields.io/pypi/v/translate.svg?maxAge=360
   :target: https://pypi.python.org/pypi/translate


Changelog
---------

3.6.1
-----

* Add LibreTranslate

3.5.0
-----

* Add sphinx documentation
* Update readme.

3.4.1
-----

* Makefile: Add a make release command
* Add twine to dev requirements.

3.4.0
-----

* Refactor: Create a folder to add all providers instead to let in a single file
* Add Microsoft provider
* Add more documentation to all providers (Translated-MyMemory and Microsoft Translator)
* Add arguments to change the default provider using translate-cli


3.3.0
-----

* Refactor translate-cli (command line interface) Using Click library instead of ArgParser
* Unify translate-cli and main to avoid duplicate code
* Add documentation to be used on helper commands on translate-cli
* Remove unnecessary code
* Refactor setup to complete information in the PKG-INFO used by PyPI


3.2.1
-----

* Change the license from "BEER-WARE" to MIT

3.2.0
-----

* Add multiple providers suport

3.1.0
-----

* Apply Solid Principles
* Organize Project
* Add pre-commit, pytest
* Add new Make file
* Add new test cases

3.0.0
-----

* General Refactor
* Remove urllib to use requests
* Refactor methods names removing google from then
* Apply PEP8
* Change contructor to keep it the code simple

2.0.0 (2017-11-08)
------------------

* initial release using changes file



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/terryyin/google-translate-python",
    "name": "translate",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "translate translation command line",
    "author": "Terry Yin",
    "author_email": "terry.yinze@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d1/9d/692066b9e26176a93ce627bf467bca48f198eb0e036337a5180d566c9561/translate-3.6.1.tar.gz",
    "platform": "",
    "description": "\n========================\nTranslate Tool in Python\n========================\n\n|PyPI latest| |PyPI Version| |PyPI License| |Docs| |Travis Build Status|\n\n\nTranslate is a simple but powerful translation tool written in python with with support for\nmultiple translation providers. By now we offer integration with Microsoft Translation API,\nTranslated MyMemory API, LibreTranslate, and DeepL's free and pro APIs\n\n\nWhy Should I Use This?\n----------------------\n\nThe biggest reason to use translate is to  make translations in a simple way without the need of bigger\neffort and can be used as a translation tool like command line\n\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n   $ pip install translate\n\nOr, you can download the source and\n\n.. code-block:: bash\n\n   $ python setup.py install\n\nPrefix 'sudo' if you encounter a problem.\n\n\nFeatures\n--------\n\n- Translate your output in real time\n- Do translation in your terminal using the command line\n\nUsage\n-----\n\nIn your command-line:\n\n.. code-block:: bash\n\n   $ translate-cli -t zh \"This is a pen.\"\n\n   Translation: \u8fd9\u662f\u4e00\u652f\u7b14\n   -------------------------\n   Translated by: MyMemory\n\nOr\n\n.. code-block:: bash\n\n   $ translate-cli -t zh \"This is a pen.\" -o\n   \u8fd9\u662f\u4e00\u652f\u7b14\n\nOptions\n~~~~~~~\n\n.. code-block:: bash\n\n    $ translate-cli --help\n    Usage: __main__.py [OPTIONS] TEXT...\n\n      Python command line tool to make online translations\n\n      Example:\n\n           $ translate-cli -t zh the book is on the table\n           \u7897\u662f\u5728\u684c\u5b50\u4e0a\u3002\n\n      Available languages:\n\n           https://en.wikipedia.org/wiki/ISO_639-1\n           Examples: (e.g. en, ja, ko, pt, zh, zh-TW, ...)\n\n    Options:\n      --version                 Show the version and exit.\n      --generate-config-file    Generate the config file using a Wizard and exit.\n      -f, --from TEXT           Sets the language of the text being translated.\n                                The default value is 'autodetect'.\n      -t, --to TEXT             Set the language you want to translate.\n      -p, --provider TEXT       Set the provider you want to use. The default\n                                value is 'mymemory'.\n      --secret_access_key TEXT  Set the secret access key used to get provider\n                                oAuth token.\n      -o, --output_only         Set to display the translation only.\n      --help                    Show this message and exit.\n\n\nChange Default Languages\n~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn ~/.python-translate.cfg:\n\n.. code-block:: bash\n\n   [DEFAULT]\n   from_lang = autodetect\n   to_lang = de\n   provider = mymemory\n   secret_access_key =\n\nThe cfg is not for use as a Python module.\n\nor run the command line and follow the steps:\n\n.. code-block:: bash\n\n    $ translate-cli --generate-config-file\n    Translate from [autodetect]:\n    Translate to: <language you want to translate>\n    Provider [mymemory]:\n    Secret Access Key []:\n\n\nUse As A Python Module\n----------------------\n\n.. code-block:: python\n\n   In [1]: from translate import Translator\n   In [2]: translator= Translator(to_lang=\"zh\")\n   In [3]: translation = translator.translate(\"This is a pen.\")\n   Out [3]: \u8fd9\u662f\u4e00\u652f\u7b14\n\nThe result is usually a unicode string.\n\n\nUse a different translation provider\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n    In [1]: from translate import Translator\n    In [2]: to_lang = 'zh'\n    In [3]: secret = '<your secret from Microsoft or DeepL>'\n    In [4]: translator = Translator(provider='<the name of the provider, eg. microsoft or deepl>', to_lang=to_lang, secret_access_key=secret)\n    In [5]: translator.translate('the book is on the table')\n    Out [5]: '\u7897\u662f\u5728\u684c\u5b50\u4e0a\u3002'\n\nThe DeepL Provider\n~~~~~~~~~~~~~~~~~~\nTo use DeepL's pro API, pass an additional parameter called pro to the Translator object and set it to True and use your pro authentication key as the secret_access_key\n\n.. code-block:: python\n\n    In: translator = Translator(provider='microsoft', to_lang=to_lang, secret_access_key=secret, pro=True)\n\nDocumentation\n-------------\n\nCheck out the latest ``translate`` documentation at `Read the Docs <http://translate-python.readthedocs.io/en/latest/>`_\n\n\nContributing\n------------\n\nPlease send pull requests, very much appreciated.\n\n\n1. Fork the `repository <https://github.com/terryyin/translate-python>`_ on GitHub.\n2. Make a branch off of master and commit your changes to it.\n3. Install requirements. ``pip install -r requirements-dev.txt``\n4. Install pre-commit. ``pre-commit install``\n5. Run the tests with ``py.test -vv -s``\n6. Create a Pull Request with your contribution\n\n\n\n.. |Docs| image:: https://readthedocs.org/projects/translate-python/badge/?version=latest\n   :target: http://translate-python.readthedocs.org/en/latest/?badge=latest\n.. |Travis Build Status| image:: https://api.travis-ci.org/terryyin/translate-python.png?branch=master\n   :target: https://travis-ci.org/terryyin/translate-python\n.. |PyPI Version| image:: https://img.shields.io/pypi/pyversions/translate.svg?maxAge=2592000\n   :target: https://pypi.python.org/pypi/translate\n.. |PyPI License| image:: https://img.shields.io/pypi/l/translate.svg?maxAge=2592000\n   :target: https://github.com/terryyin/translate-python/blob/master/LICENSE\n.. |PyPI latest| image:: https://img.shields.io/pypi/v/translate.svg?maxAge=360\n   :target: https://pypi.python.org/pypi/translate\n\n\nChangelog\n---------\n\n3.6.1\n-----\n\n* Add LibreTranslate\n\n3.5.0\n-----\n\n* Add sphinx documentation\n* Update readme.\n\n3.4.1\n-----\n\n* Makefile: Add a make release command\n* Add twine to dev requirements.\n\n3.4.0\n-----\n\n* Refactor: Create a folder to add all providers instead to let in a single file\n* Add Microsoft provider\n* Add more documentation to all providers (Translated-MyMemory and Microsoft Translator)\n* Add arguments to change the default provider using translate-cli\n\n\n3.3.0\n-----\n\n* Refactor translate-cli (command line interface) Using Click library instead of ArgParser\n* Unify translate-cli and main to avoid duplicate code\n* Add documentation to be used on helper commands on translate-cli\n* Remove unnecessary code\n* Refactor setup to complete information in the PKG-INFO used by PyPI\n\n\n3.2.1\n-----\n\n* Change the license from \"BEER-WARE\" to MIT\n\n3.2.0\n-----\n\n* Add multiple providers suport\n\n3.1.0\n-----\n\n* Apply Solid Principles\n* Organize Project\n* Add pre-commit, pytest\n* Add new Make file\n* Add new test cases\n\n3.0.0\n-----\n\n* General Refactor\n* Remove urllib to use requests\n* Refactor methods names removing google from then\n* Apply PEP8\n* Change contructor to keep it the code simple\n\n2.0.0 (2017-11-08)\n------------------\n\n* initial release using changes file\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This is a simple, yet powerful command line translator with google translate behind it. You can also use it as a Python module in your code.",
    "version": "3.6.1",
    "split_keywords": [
        "translate",
        "translation",
        "command",
        "line"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e154df0d3e62636f291d716caa44c5c9590af8e6f225c59d7874051da6428c06",
                "md5": "22b4da9b2a0c76899a9b0a5d64e1694d",
                "sha256": "cebfb004989d9a2ab0d24c0c5805783c7f4e07243ea4ed2a8f1809d072bf712b"
            },
            "downloads": -1,
            "filename": "translate-3.6.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "22b4da9b2a0c76899a9b0a5d64e1694d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 12702,
            "upload_time": "2021-07-06T03:27:16",
            "upload_time_iso_8601": "2021-07-06T03:27:16.177248Z",
            "url": "https://files.pythonhosted.org/packages/e1/54/df0d3e62636f291d716caa44c5c9590af8e6f225c59d7874051da6428c06/translate-3.6.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d19d692066b9e26176a93ce627bf467bca48f198eb0e036337a5180d566c9561",
                "md5": "3ebcafb25c270e785c5f18580c4ad0c4",
                "sha256": "7e70ffa46f193cc744be7c88b8e1323f10f6b2bb90d24bb5d29fdf1e56618783"
            },
            "downloads": -1,
            "filename": "translate-3.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3ebcafb25c270e785c5f18580c4ad0c4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18261,
            "upload_time": "2021-07-06T03:27:19",
            "upload_time_iso_8601": "2021-07-06T03:27:19.574662Z",
            "url": "https://files.pythonhosted.org/packages/d1/9d/692066b9e26176a93ce627bf467bca48f198eb0e036337a5180d566c9561/translate-3.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-07-06 03:27:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "terryyin",
    "github_project": "google-translate-python",
    "travis_ci": true,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "click",
            "specs": []
        },
        {
            "name": "lxml",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "libretranslatepy",
            "specs": [
                [
                    "==",
                    "2.1.1"
                ]
            ]
        }
    ],
    "lcname": "translate"
}
        
Elapsed time: 0.04463s