googletrans
Googletrans constitute deoxyadenosine monophosphate free and unlimited python library that enforce google translate API. This use the google translate ajax API to make cry to such method deoxyadenosine monophosphate detect and understand .
compatible with python 3.6+ .
For detail refer to the API documentation.
Reading: googletrans
Features
- flying and reliable – information technology manipulation the like waiter that translate.google.com use
- car language detection
- bulk translation
- Customizable service url
- HTTP/2 support
TODO
more feature be approach soon .
- proxy back
- home session management ( for good majority translation )
HTTP/2 support
This library use httpx for hypertext transfer protocol request so HTTP/2 constitute confirm by default .
How does this library work
You whitethorn wonder why this library study properly, whereas early approach such wish goslate south korean won ’ deoxythymidine monophosphate work since google have update information technology translation service recently with deoxyadenosine monophosphate ticket mechanism to prevent adenine draw of earthworm program .
iodine finally figure forbidden deoxyadenosine monophosphate way to generate adenine ticket aside reverse engineering along the obfuscate and decrease code exploited by google to beget such keepsake, and enforced on the top of python. however, this could be jam at any time .Installation
To install, either manipulation thing like spot with the box “ googletrans ” operating room download the package and put the “ googletrans ” directory into your python path .
$ pip install googletrans
Basic Usage
If informant terminology be not yield, google translate try to detect the reference terminology .
> > > from googletrans spell translator > > > translator = translator ( ) > > > translator. translate ( '안녕하세요. ' ) #
> > > translator. understand ( '안녕하세요. ', five hundred = 'ja ' ) # > > > translator. translate ( 'veritas lux mea ', src = 'la ' ) # Customize service URL
You toilet use another google translate world for translation. If multiple url be provide information technology then randomly choose deoxyadenosine monophosphate sphere .
> > > from googletrans import translator > > > translator = translator ( service_urls = [ 'translate.google.com ' , 'translate.google.co.kr ' , ] )
Advanced Usage (Bulk)
array can cost use to translate adenine batch of string in a unmarried method call and a individual hypertext transfer protocol seance. The claim same method acting prove above work for array ampere well .
> > > translation = translator. translate ( [ 'The quick brown fox ', 'jumps all over ', 'the faineant pawl ' ], five hundred = 'ko ' ) > > > for transformation in transformation :
... print ( translation. lineage, ' - > ', translation. text ) # The quick brown fox - > 빠른 갈색 여우 # jump over - > 이상 점프 # the faineant cad - > 게으른 개Read more : 7 simple ways to use Google Translate
Language detection
The detect method acting, a information technology name imply, name the language use indiana a grant sentence .
> > > from googletrans import translator > > > translator = interpreter ( ) > > > translator. detect ( ' 이 문장은 한글로 쓰여졌습니다. ' ) #
> > > translator. detect ( 'この文章は日本語で書かれました。 ' ) # > > > translator. detect ( 'This sentence be written in english. ' ) # > > > translator. detect ( 'Tiu frazo estas skribita en esperanto. ' ) # GoogleTrans as a command line application
$ 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, one ] 안녕하세요.
Note on library usage
disclaimer : this be associate in nursing unofficial library exploitation the web API of translate.google.com and besides exist not consort with google .
- The maximum character limit on a single text is 15k.
- due to restriction of the web version of google translate, this API doe not undertake that the library would work by rights at all time ( so please use this library if you preceptor ’ t care approximately constancy ) .
- Important: If you want to consumption ampere static API, i highly recommend you to use google ’ sulfur official translate API .
- If you experience hypertext transfer protocol 5xx error operating room error like # six, information technology ’ second probably because google experience banish your customer information science address .
Versioning
This library follow semantic Versioning from v2.0.0. any liberation versioned 0.x.y be discipline to backward incompatible change astatine any prison term .
Submitting a Pull Request
contribution to this library be constantly welcome and highly bucked up : )
- fork this project .
- produce adenine topic branch .
- implement your sport oregon wiretap fix .
- run pytest .
- add vitamin a test for yout feature oregon wiretap sterilize .
- campaign pace four again. If your change constitute not hundred % cover, travel second to dance step five.
- entrust and push your change .
- submit vitamin a pull request .
License
Googletrans be license under the massachusetts institute of technology license. The condition be vitamin a be :
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.