vtrans


Namevtrans JSON
Version 3.5.0 PyPI version JSON
download
home_pagehttps://github.com/megalosVigneswaran/vtrans/tree/main/vtrans
SummaryThis is a cross-platfrom self-updating translator for free and unlimited usage with upto 130 langauges
upload_time2023-08-08 18:41:52
maintainer
docs_urlNone
authorS.Vigneswaran
requires_python
licenseMIT
keywords translator googletranslate self-updating googletrans vtrans
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # vtrans
[![GitHub
license](https://img.shields.io/github/license/mashape/apistatus.svg)](http://opensource.org/licenses/MIT)
[![PyPI
version](https://badge.fury.io/py/googletrans.svg)](https://pypi.org/project/vtrans/)

**vtrans** is a **self-updating**, **free**, and **unlimited** language
translating library. It works with the
[googletrans](https://pypi.org/project/googletrans2/) library.

**Wait**, but this is not like googletrans.
googletrans can\'t update its languages, so you can only
use limited languages. However, **vtrans** is different. It
updates itself every time you import it.

# Features

## Different from googletrans

-   update it self
-   You can use exatra langauges like sansrit,bhojpuri ect\...\.... .
-   but googletrans have not this languages
-   When the google update their google translator it automatically
    update it self
-   you can use extra languages compare to other translating library
-   what langauges are avaiable in google translator,you can use all the
    languages by this library

## Similarities with googletrans

-   Fast and reliable: It uses the same servers as
    translate.google.com.
-   Auto language detection
-   Bulk translations
-   HTTP/2 support
-   Similar structure

# How it works

vtrans is essentially a language-updatable version of
googletrans. It modifies the LANGUAGES
dictionary in constants.py of googletrans by
scraping the table from [google translator supported
langauges](https://cloud.google.com/translate/docs/languages). It
retrieves the values from the table and creates a new dictionary, which
replaces the existing LANGUAGES dictionary.

# Installing

To install the vtrans package, use the following command:

``` bash
$ pip install vtrans==3.0.0
```

# How to use this library (simple)

``` python
from vtrans import Translator

translator = Translator()
output = translator.translate("This library can translate languages", "ta")
```

# Find available languages

To find what languages are available in vtrans:

``` python
import vtrans

langs = vtrans.LANGUAGES
print(langs)  # It will give you a dictionary

# To find the number of available languages
print(len(langs))
```

# First importing of vtrans

If you import this library for the first time, it will take some time to
complete the configurations. It changes the LANGUAGES
variable in constants.py of googletrans to
match the current version of Google Translator. The first import will
display the following:

``` python
import vtrans

# Setup config file
# Checking for updates (auto-updating). If you want to stop auto-updating, use this code: `vtrans.config(auto_updating=False)`
# Please wait for a few seconds, the update is in progress...
# Update finished. Now you can use extra languages.
# Ready to translate
```

Once you have imported vtrans for the first time, you do
not need to use auto-updating. Auto-updating slows down the library, as
it searches for updates whenever you import vtrans.
Enabling or disabling auto-updating is based on your needs and choice.

# How to disable auto-update

If you want to disable auto-updating:

``` python
import vtrans

vtrans.config(auto_updating=False)
```

Now vtrans will not update whenever you import it.

# How to update manually

If you want to update manually, make sure you have disabled
auto-updating:

``` python
import vtrans

vtrans.update()
```

Now the languages are updated manually.

# How to disable unwanted printing

Whenever vtrans is initialized and ready to translate, it
prints \"Ready to translate\". If you want to disable this:

``` python
import vtrans

vtrans.remove_unwanted_printing()
```

You don\'t need to do this every time. Once you have changed the value,
it will make changes in the config.txt file.

# HTTP/2 support

This library uses httpx for HTTP requests, so HTTP/2 is
supported by default. You can check if HTTP/2 is enabled and working by
accessing the .\_response.http_version attribute of the
Translated or Detected object:

``` python
from vtrans import Translator
translator = Translator()
translator.translate('테스트')._response.http_version
# 'HTTP/2'
```

Basic Usage ==========

If the source language is not given, Google Translate attempts to detect
the source language.

``` python
from vtrans import Translator

translator = Translator()
translator.translate('안녕하세요.')
# <Translated src=ko dest=en text=Good evening. pronunciation=Good evening.>
translator.translate('안녕하세요.', dest='ja')
# <Translated src=ko dest=ja text=こんにちは。 pronunciation=Kon'nichiwa.>
translator.translate('veritas lux mea', src='la')
# <Translated src=la dest=en text=The truth is my light pronunciation=The truth is my light>
```

# Customize service URL

You can use a different Google Translate domain for translation. If
multiple URLs are provided, it randomly chooses a domain.

``` python
from vtrans import Translator

translator = Translator(service_urls=[
    'translate.google.com',
    'translate.google.co.kr',
])
```

# Advanced Usage (Bulk)

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

``` python
translations = 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  ->  게으른 개
```

# Language detection

The detect method identifies the language used in a given
sentence.

``` python
from vtrans import Translator

translator = Translator()
translator.detect('이 문장은 한글로 쓰여졌습니다.')
# <Detected lang=ko confidence=0.27041003>
translator.detect('この文章は日本語で書かれました。')
# <Detected lang=ja confidence=0.64889508>
translator.detect('This sentence is written in English.')
# <Detected lang=en confidence=0.22348526>
translator.detect('Tiu frazo estas skribita en Esperanto.')
# <Detected lang=eo confidence=0.10538048>
```

# Note on library usage

DISCLAIMER: Yes, I am aware that most of the functions are similar to
googletrans because I worked with the base of
googletrans. However, vtrans can update its
languages, allowing you to use more languages. This is an unofficial
library that uses the web API of translate.google.com and 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 stability at all times. Please use this library
    if you don\'t require stability.
-   If you encounter HTTP 5xx errors or errors like #6, it is likely
    because Google has banned your client IP address.

# License

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


Copyright 2023 S.Vigneswaran

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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/megalosVigneswaran/vtrans/tree/main/vtrans",
    "name": "vtrans",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "translator,googletranslate,self-updating,googletrans,vtrans",
    "author": "S.Vigneswaran",
    "author_email": "t896242@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/48/b6/92065c9f9bd275dcae6ae234005aeb6f4f82f1e4a8212264a8488583ef2b/vtrans-3.5.0.tar.gz",
    "platform": null,
    "description": "# vtrans\r\n[![GitHub\r\nlicense](https://img.shields.io/github/license/mashape/apistatus.svg)](http://opensource.org/licenses/MIT)\r\n[![PyPI\r\nversion](https://badge.fury.io/py/googletrans.svg)](https://pypi.org/project/vtrans/)\r\n\r\n**vtrans** is a **self-updating**, **free**, and **unlimited** language\r\ntranslating library. It works with the\r\n[googletrans](https://pypi.org/project/googletrans2/) library.\r\n\r\n**Wait**, but this is not like googletrans.\r\ngoogletrans can\\'t update its languages, so you can only\r\nuse limited languages. However, **vtrans** is different. It\r\nupdates itself every time you import it.\r\n\r\n# Features\r\n\r\n## Different from googletrans\r\n\r\n-   update it self\r\n-   You can use exatra langauges like sansrit,bhojpuri ect\\...\\.... .\r\n-   but googletrans have not this languages\r\n-   When the google update their google translator it automatically\r\n    update it self\r\n-   you can use extra languages compare to other translating library\r\n-   what langauges are avaiable in google translator,you can use all the\r\n    languages by this library\r\n\r\n## Similarities with googletrans\r\n\r\n-   Fast and reliable: It uses the same servers as\r\n    translate.google.com.\r\n-   Auto language detection\r\n-   Bulk translations\r\n-   HTTP/2 support\r\n-   Similar structure\r\n\r\n# How it works\r\n\r\nvtrans is essentially a language-updatable version of\r\ngoogletrans. It modifies the LANGUAGES\r\ndictionary in constants.py of googletrans by\r\nscraping the table from [google translator supported\r\nlangauges](https://cloud.google.com/translate/docs/languages). It\r\nretrieves the values from the table and creates a new dictionary, which\r\nreplaces the existing LANGUAGES dictionary.\r\n\r\n# Installing\r\n\r\nTo install the vtrans package, use the following command:\r\n\r\n``` bash\r\n$ pip install vtrans==3.0.0\r\n```\r\n\r\n# How to use this library (simple)\r\n\r\n``` python\r\nfrom vtrans import Translator\r\n\r\ntranslator = Translator()\r\noutput = translator.translate(\"This library can translate languages\", \"ta\")\r\n```\r\n\r\n# Find available languages\r\n\r\nTo find what languages are available in vtrans:\r\n\r\n``` python\r\nimport vtrans\r\n\r\nlangs = vtrans.LANGUAGES\r\nprint(langs)  # It will give you a dictionary\r\n\r\n# To find the number of available languages\r\nprint(len(langs))\r\n```\r\n\r\n# First importing of vtrans\r\n\r\nIf you import this library for the first time, it will take some time to\r\ncomplete the configurations. It changes the LANGUAGES\r\nvariable in constants.py of googletrans to\r\nmatch the current version of Google Translator. The first import will\r\ndisplay the following:\r\n\r\n``` python\r\nimport vtrans\r\n\r\n# Setup config file\r\n# Checking for updates (auto-updating). If you want to stop auto-updating, use this code: `vtrans.config(auto_updating=False)`\r\n# Please wait for a few seconds, the update is in progress...\r\n# Update finished. Now you can use extra languages.\r\n# Ready to translate\r\n```\r\n\r\nOnce you have imported vtrans for the first time, you do\r\nnot need to use auto-updating. Auto-updating slows down the library, as\r\nit searches for updates whenever you import vtrans.\r\nEnabling or disabling auto-updating is based on your needs and choice.\r\n\r\n# How to disable auto-update\r\n\r\nIf you want to disable auto-updating:\r\n\r\n``` python\r\nimport vtrans\r\n\r\nvtrans.config(auto_updating=False)\r\n```\r\n\r\nNow vtrans will not update whenever you import it.\r\n\r\n# How to update manually\r\n\r\nIf you want to update manually, make sure you have disabled\r\nauto-updating:\r\n\r\n``` python\r\nimport vtrans\r\n\r\nvtrans.update()\r\n```\r\n\r\nNow the languages are updated manually.\r\n\r\n# How to disable unwanted printing\r\n\r\nWhenever vtrans is initialized and ready to translate, it\r\nprints \\\"Ready to translate\\\". If you want to disable this:\r\n\r\n``` python\r\nimport vtrans\r\n\r\nvtrans.remove_unwanted_printing()\r\n```\r\n\r\nYou don\\'t need to do this every time. Once you have changed the value,\r\nit will make changes in the config.txt file.\r\n\r\n# HTTP/2 support\r\n\r\nThis library uses httpx for HTTP requests, so HTTP/2 is\r\nsupported by default. You can check if HTTP/2 is enabled and working by\r\naccessing the .\\_response.http_version attribute of the\r\nTranslated or Detected object:\r\n\r\n``` python\r\nfrom vtrans import Translator\r\ntranslator = Translator()\r\ntranslator.translate('\ud14c\uc2a4\ud2b8')._response.http_version\r\n# 'HTTP/2'\r\n```\r\n\r\nBasic Usage ==========\r\n\r\nIf the source language is not given, Google Translate attempts to detect\r\nthe source language.\r\n\r\n``` python\r\nfrom vtrans import Translator\r\n\r\ntranslator = Translator()\r\ntranslator.translate('\uc548\ub155\ud558\uc138\uc694.')\r\n# <Translated src=ko dest=en text=Good evening. pronunciation=Good evening.>\r\ntranslator.translate('\uc548\ub155\ud558\uc138\uc694.', dest='ja')\r\n# <Translated src=ko dest=ja text=\u3053\u3093\u306b\u3061\u306f\u3002 pronunciation=Kon'nichiwa.>\r\ntranslator.translate('veritas lux mea', src='la')\r\n# <Translated src=la dest=en text=The truth is my light pronunciation=The truth is my light>\r\n```\r\n\r\n# Customize service URL\r\n\r\nYou can use a different Google Translate domain for translation. If\r\nmultiple URLs are provided, it randomly chooses a domain.\r\n\r\n``` python\r\nfrom vtrans import Translator\r\n\r\ntranslator = Translator(service_urls=[\r\n    'translate.google.com',\r\n    'translate.google.co.kr',\r\n])\r\n```\r\n\r\n# Advanced Usage (Bulk)\r\n\r\nArrays can be used to translate a batch of strings in a single method\r\ncall and a single HTTP session. The same method shown above also works\r\nfor arrays.\r\n\r\n``` python\r\ntranslations = translator.translate(['The quick brown fox', 'jumps over', 'the lazy dog'], dest='ko')\r\nfor translation in translations:\r\n    print(translation.origin, ' -> ', translation.text)\r\n# The quick brown fox  ->  \ube60\ub978 \uac08\uc0c9 \uc5ec\uc6b0\r\n# jumps over  ->  \uc774\uc0c1 \uc810\ud504\r\n# the lazy dog  ->  \uac8c\uc73c\ub978 \uac1c\r\n```\r\n\r\n# Language detection\r\n\r\nThe detect method identifies the language used in a given\r\nsentence.\r\n\r\n``` python\r\nfrom vtrans import Translator\r\n\r\ntranslator = Translator()\r\ntranslator.detect('\uc774 \ubb38\uc7a5\uc740 \ud55c\uae00\ub85c \uc4f0\uc5ec\uc84c\uc2b5\ub2c8\ub2e4.')\r\n# <Detected lang=ko confidence=0.27041003>\r\ntranslator.detect('\u3053\u306e\u6587\u7ae0\u306f\u65e5\u672c\u8a9e\u3067\u66f8\u304b\u308c\u307e\u3057\u305f\u3002')\r\n# <Detected lang=ja confidence=0.64889508>\r\ntranslator.detect('This sentence is written in English.')\r\n# <Detected lang=en confidence=0.22348526>\r\ntranslator.detect('Tiu frazo estas skribita en Esperanto.')\r\n# <Detected lang=eo confidence=0.10538048>\r\n```\r\n\r\n# Note on library usage\r\n\r\nDISCLAIMER: Yes, I am aware that most of the functions are similar to\r\ngoogletrans because I worked with the base of\r\ngoogletrans. However, vtrans can update its\r\nlanguages, allowing you to use more languages. This is an unofficial\r\nlibrary that uses the web API of translate.google.com and is not\r\nassociated with Google.\r\n\r\n-   The maximum character limit on a single text is 15k.\r\n-   Due to limitations of the web version of Google Translate, this API\r\n    does not guarantee stability at all times. Please use this library\r\n    if you don\\'t require stability.\r\n-   If you encounter HTTP 5xx errors or errors like #6, it is likely\r\n    because Google has banned your client IP address.\r\n\r\n# License\r\n\r\nGoogletrans is licensed under the MIT License. The terms are as follows:\r\n\r\n\r\nCopyright 2023 S.Vigneswaran\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a\r\ncopy of this software and associated documentation files (the\r\n\"Software\"), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, sublicense, and/or sell copies of the Software, and to\r\npermit persons to whom the Software is furnished to do so, subject to\r\nthe following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included\r\nin all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This is a cross-platfrom self-updating translator for free and unlimited usage with upto 130 langauges",
    "version": "3.5.0",
    "project_urls": {
        "Homepage": "https://github.com/megalosVigneswaran/vtrans/tree/main/vtrans"
    },
    "split_keywords": [
        "translator",
        "googletranslate",
        "self-updating",
        "googletrans",
        "vtrans"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48b692065c9f9bd275dcae6ae234005aeb6f4f82f1e4a8212264a8488583ef2b",
                "md5": "62dafb160191e9a67d419ec89ef62985",
                "sha256": "fa38d816ebd808ef67f24334f3b69c62e1bd5478db800fcdc518064eb3bbb1ba"
            },
            "downloads": -1,
            "filename": "vtrans-3.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "62dafb160191e9a67d419ec89ef62985",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8375,
            "upload_time": "2023-08-08T18:41:52",
            "upload_time_iso_8601": "2023-08-08T18:41:52.624361Z",
            "url": "https://files.pythonhosted.org/packages/48/b6/92065c9f9bd275dcae6ae234005aeb6f4f82f1e4a8212264a8488583ef2b/vtrans-3.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-08 18:41:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "megalosVigneswaran",
    "github_project": "vtrans",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "vtrans"
}
        
Elapsed time: 0.10710s