All Projects → Saravananslb → py-googletranslation

Saravananslb / py-googletranslation

Licence: MIT license
pygoogletranslation: Free and Unlimited Google translate API for Python. Translates totally free of charge.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to py-googletranslation

fanyi-bot
🤖 Telegram 上的谷歌翻译机器人,为全世界语言提供中文翻译。
Stars: ✭ 100 (+35.14%)
Mutual labels:  translation, googletranslate
Trakt-Userscripts
Userscripts to improve and add features to Trakt.tv
Stars: ✭ 39 (-47.3%)
Mutual labels:  translation
yandex-translate-api
A simple REST client library for Yandex.Translate
Stars: ✭ 29 (-60.81%)
Mutual labels:  translation
dokuwiki-plugin-translation
Easily setup a multi-language DokuWiki
Stars: ✭ 22 (-70.27%)
Mutual labels:  translation
YuzuMarker
🍋 [WIP] Manga Translation Tool
Stars: ✭ 76 (+2.7%)
Mutual labels:  translation
lost-in-translation
Uncover missing translations and localization strings in Laravel applications.
Stars: ✭ 32 (-56.76%)
Mutual labels:  translation
HPO-translations
Internationalisation of the HPO content
Stars: ✭ 19 (-74.32%)
Mutual labels:  translation
gf-wordnet
A WordNet in GF
Stars: ✭ 15 (-79.73%)
Mutual labels:  translation
SimpleTranslationSystem
A simple C# translation system
Stars: ✭ 14 (-81.08%)
Mutual labels:  translation
redux-saga-in-korean
redux-saga 공식문서의 한국어 번역 프로젝트.
Stars: ✭ 73 (-1.35%)
Mutual labels:  translation
BIFI
[ICML 2021] Break-It-Fix-It: Unsupervised Learning for Program Repair
Stars: ✭ 74 (+0%)
Mutual labels:  translation
bem-flashcards
Simple single-page flashcards application based on the bem-core/bem-history and BEM methodology
Stars: ✭ 19 (-74.32%)
Mutual labels:  translation
ribotricer
A tool for accurately detecting actively translating ORFs from Ribo-seq data
Stars: ✭ 20 (-72.97%)
Mutual labels:  translation
Effective-Java-3rd-Edition-zh
📖 Effective Java (Third Edition) | Effective Java(第三版)翻译计划稿
Stars: ✭ 57 (-22.97%)
Mutual labels:  translation
i18n.cr
Internationalization API ( i18n ) for Crystal!
Stars: ✭ 36 (-51.35%)
Mutual labels:  translation
deepl-api-connector
Connector library for deepl.com rest translation api
Stars: ✭ 12 (-83.78%)
Mutual labels:  translation
Localisation
Repository for translation and discussion for OpenRCT2.
Stars: ✭ 49 (-33.78%)
Mutual labels:  translation
series-formelles
Translation of, and commentary on, Joyal's classic paper "Une théorie combinatoire des séries formelles" (A combinatorial theory of formal series)
Stars: ✭ 24 (-67.57%)
Mutual labels:  translation
de-DE
Special German permalink sanitize
Stars: ✭ 45 (-39.19%)
Mutual labels:  translation
codeX
CodeX is a platform which converts code into easy to understand language.
Stars: ✭ 46 (-37.84%)
Mutual labels:  googletrans

PYGOOGLETRANSLATION

https://pypi.org/project/pygoogletranslation/

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

Unlimited Text Translation (no limitation)

pygoogletranslation 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.6+.

Features

  • Translation from file (.doc, .docx, .pdf, .txt)
  • Fast and reliable - it uses the same servers that translate.google.com uses
  • Auto language detection
  • Bulk translations
  • Request

TODO

more features are coming soon.

  • Proxy support
  • Internal session management (for better bulk translations)

Python Request Module

This library uses request to get an data from google.

Request :
POST GET

How does this library work

You may wonder how this library works properly, whereas other python translation package use the token mechanism but that is failling because google has changed their token mechanism.


Installation

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

$ pip install pygoogletranslation

Basic Usage

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

>>> from pygoogletranslation import Translator
>>> translator = Translator()
>>> translator.translate('Good Morning', dest='ta')
# <Translated src=ko dest=ta text=காலை வணக்கம். 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 proxy URL

You can use proxies in the translation.

>>> from pygoogletranslation import Translator
>>> proxy = {"http":"http://sampleproxy.com:80"}
>>> translator = Translator(proxies=proxy)

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.

>>> from pygoogletranslation import Translator
>>> translator = Translator()
>>> t = (translator.translate(["Good ' Morning", "India"], dest="ta"))
>>> for _t in t:
>>>     print(_t.text)
# காலை வணக்கம்
# இந்தியா

Language detection

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

>>> from pygoogletranslation import Translator
>>> translator = Translator()
>>> translator.detect('காலை வணக்கம்,')
# <Detected lang=ta confidence=0.72041003>
>>> 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>

Translation from document (.doc, .docx, .pdf, .txt):

>>> from pygoogletranslation import Translator
>>> translator = Translator()
>>> translator.bulktranslate('test.txt', dest="ta")
# <bulk translated text>
# for bulk translation, sometimes you might get an error with response
# code "429" - Too Many attempts.
# To overcome this error, add below parameter.
>>> translator = Translator(retry=NO_OF_ATTEMPTS, sleep=WAIT_SECONDS, retry_message=TRUE)
>>> translator.bulktranslate('test.txt', dest="ta")
# retry - no of attemps (default- 3 times)
# sleep - no of attempts after seconds (default- 5 seconds)
# retry_message - True - display retrying message (default- False)

pygoogletranslation to get Language and Language Codes

>>> from pygoogletranslation import Translator
>>> translator = Translator()
>>> translator.glanguage()
>>> {
   "sl": {
   "auto": "Detect language",
   "af": "Afrikaans",
   "sq": "Albanian",
   "am": "Amharic",
   "ar": "Arabic",
   "hy": "Armenian",
   "az": "Azerbaijani",
   "eu": "Basque",
   "be": "Belarusian",
   "bn": "Bengali",
   "bs": "Bosnian",
   "bg": "Bulgarian",
   "ca": "Catalan",
   "ceb": "Cebuano",
   "ny": "Chichewa",
   "zh-CN": "Chinese",
   "co": "Corsican",
   "hr": "Croatian",
   "cs": "Czech",
   "da": "Danish",
   "nl": "Dutch",
   "en": "English",
   "eo": "Esperanto",
   "et": "Estonian",
   "tl": "Filipino",
   "fi": "Finnish",
   "fr": "French",
   "fy": "Frisian",
   "gl": "Galician",
   "ka": "Georgian",
   "de": "German",
   "el": "Greek",
   "gu": "Gujarati",
   "ht": "Haitian Creole",
   "ha": "Hausa",
   "haw": "Hawaiian",
   "iw": "Hebrew",
   "hi": "Hindi",
   "hmn": "Hmong",
   "hu": "Hungarian",
   "is": "Icelandic",
   "ig": "Igbo",
   "id": "Indonesian",
   "ga": "Irish",
   "it": "Italian",
   "ja": "Japanese",
   "jw": "Javanese",
   "kn": "Kannada",
   "kk": "Kazakh",
   "km": "Khmer",
   "rw": "Kinyarwanda",
   "ko": "Korean",
   "ku": "Kurdish (Kurmanji)",
   "ky": "Kyrgyz",
   "lo": "Lao",
   "la": "Latin",
   "lv": "Latvian",
   "lt": "Lithuanian",
   "lb": "Luxembourgish",
   "mk": "Macedonian",
   "mg": "Malagasy",
   "ms": "Malay",
   "ml": "Malayalam",
   "mt": "Maltese",
   "mi": "Maori",
   "mr": "Marathi",
   "mn": "Mongolian",
   "my": "Myanmar (Burmese)",
   "ne": "Nepali",
   "no": "Norwegian",
   "or": "Odia (Oriya)",
   "ps": "Pashto",
   "fa": "Persian",
   "pl": "Polish",
   "pt": "Portuguese",
   "pa": "Punjabi",
   "ro": "Romanian",
   "ru": "Russian",
   "sm": "Samoan",
   "gd": "Scots Gaelic",
   "sr": "Serbian",
   "st": "Sesotho",
   "sn": "Shona",
   "sd": "Sindhi",
   "si": "Sinhala",
   "sk": "Slovak",
   "sl": "Slovenian",
   "so": "Somali",
   "es": "Spanish",
   "su": "Sundanese",
   "sw": "Swahili",
   "sv": "Swedish",
   "tg": "Tajik",
   "ta": "Tamil",
   "tt": "Tatar",
   "te": "Telugu",
   "th": "Thai",
   "tr": "Turkish",
   "tk": "Turkmen",
   "uk": "Ukrainian",
   "ur": "Urdu",
   "ug": "Uyghur",
   "uz": "Uzbek",
   "vi": "Vietnamese",
   "cy": "Welsh",
   "xh": "Xhosa",
   "yi": "Yiddish",
   "yo": "Yoruba",
   "zu": "Zulu"
   },
   "tl": {
   "af": "Afrikaans",
   "sq": "Albanian",
   "am": "Amharic",
   "ar": "Arabic",
   "hy": "Armenian",
   "az": "Azerbaijani",
   "eu": "Basque",
   "be": "Belarusian",
   "bn": "Bengali",
   "bs": "Bosnian",
   "bg": "Bulgarian",
   "ca": "Catalan",
   "ceb": "Cebuano",
   "ny": "Chichewa",
   "zh-CN": "Chinese (Simplified)",
   "zh-TW": "Chinese (Traditional)",
   "co": "Corsican",
   "hr": "Croatian",
   "cs": "Czech",
   "da": "Danish",
   "nl": "Dutch",
   "en": "English",
   "eo": "Esperanto",
   "et": "Estonian",
   "tl": "Filipino",
   "fi": "Finnish",
   "fr": "French",
   "fy": "Frisian",
   "gl": "Galician",
   "ka": "Georgian",
   "de": "German",
   "el": "Greek",
   "gu": "Gujarati",
   "ht": "Haitian Creole",
   "ha": "Hausa",
   "haw": "Hawaiian",
   "iw": "Hebrew",
   "hi": "Hindi",
   "hmn": "Hmong",
   "hu": "Hungarian",
   "is": "Icelandic",
   "ig": "Igbo",
   "id": "Indonesian",
   "ga": "Irish",
   "it": "Italian",
   "ja": "Japanese",
   "jw": "Javanese",
   "kn": "Kannada",
   "kk": "Kazakh",
   "km": "Khmer",
   "rw": "Kinyarwanda",
   "ko": "Korean",
   "ku": "Kurdish (Kurmanji)",
   "ky": "Kyrgyz",
   "lo": "Lao",
   "la": "Latin",
   "lv": "Latvian",
   "lt": "Lithuanian",
   "lb": "Luxembourgish",
   "mk": "Macedonian",
   "mg": "Malagasy",
   "ms": "Malay",
   "ml": "Malayalam",
   "mt": "Maltese",
   "mi": "Maori",
   "mr": "Marathi",
   "mn": "Mongolian",
   "my": "Myanmar (Burmese)",
   "ne": "Nepali",
   "no": "Norwegian",
   "or": "Odia (Oriya)",
   "ps": "Pashto",
   "fa": "Persian",
   "pl": "Polish",
   "pt": "Portuguese",
   "pa": "Punjabi",
   "ro": "Romanian",
   "ru": "Russian",
   "sm": "Samoan",
   "gd": "Scots Gaelic",
   "sr": "Serbian",
   "st": "Sesotho",
   "sn": "Shona",
   "sd": "Sindhi",
   "si": "Sinhala",
   "sk": "Slovak",
   "sl": "Slovenian",
   "so": "Somali",
   "es": "Spanish",
   "su": "Sundanese",
   "sw": "Swahili",
   "sv": "Swedish",
   "tg": "Tajik",
   "ta": "Tamil",
   "tt": "Tatar",
   "te": "Telugu",
   "th": "Thai",
   "tr": "Turkish",
   "tk": "Turkmen",
   "uk": "Ukrainian",
   "ur": "Urdu",
   "ug": "Uyghur",
   "uz": "Uzbek",
   "vi": "Vietnamese",
   "cy": "Welsh",
   "xh": "Xhosa",
   "yi": "Yiddish",
   "yo": "Yoruba",
   "zu": "Zulu"
   },
   "al": {}
   }

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.

  • 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

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

:: MIT License

Copyright (c) 2021 Saravananslb

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].