Simple and fast, what else?
Fully working Google Translate API for python 2.7 and 3.x
As simple as that:
translate("Bonjour","en","auto")
will return "Hello"
Also on PyPi: https://pypi.python.org/pypi?:action=display&name=mtranslate
A simple api for google translate
License: MIT License
Simple and fast, what else?
Fully working Google Translate API for python 2.7 and 3.x
As simple as that:
translate("Bonjour","en","auto")
will return "Hello"
Also on PyPi: https://pypi.python.org/pypi?:action=display&name=mtranslate
Hey, Cool library, very useful. Just wanted to ask, since html parsing is used here.... Would HTML Parsing in this module be faster than using another module which uses rpc's to make requests from the server? Both are blazing fast but I just want to know if you guys might have some more insight.
Also, is it possible to set it to only use one gender-translation (if you try and translate "they" to french it will result in both gender translations since translate.google.com displays both in different fields the translation returns "ils ou elles" which means "they(m) or they(f)) so as to prevent the merging of two different gender translations into the returned translation.
Hello,
Thanks for this library. I got this error when characters lenth is 6000. I tried with 3000 characters but still same error. What is the character limit here?
The python3 version wasn't working for me with Arabic input language. It seems like it might be broken with all non ascii letter systems. However there is a way to first convert the text to an HTML escape code then send it to you function with the following code:
def convertUnicodeToHTMLEsc(text):
htmlEsc = str(text.encode()).replace("b'\x", "%").replace("\x", "%").replace("'", '')
return htmlEsc
then after the comment in your function put this line:
to_translate = convertUnicodeToHTMLEsc(to_translate)
I am more of a code hacker than a coder so there might be a easier way but this works.
Hello! I am new to NLP. Would like to ask is it possible to fine tune mtranslate with our own dataset prepared? Might I ask how to do it?
Traceback (most recent call last):
File "C:\Users\localadmin\AppData\Roaming\Python\Python39\site-packages\guilded\__main__.py", line 201, in websocket_process
await c(*ctx.arguments)
File "c:\RitaBot\PythonGuilded\bot.py", line 45, in translate
translate1 = translate(argstr, Lang, "auto")
TypeError: 'NoneType' object is not callable
I'm using it like follows:
import mtranslate
from mtranslate import translate
def converttostr(input_seq, seperator):
# Join all strings in list
final_str = seperator.join(input_seq)
return final_str
def translate(ctx, *args):
message = ctx.message.content
message = message[11:]
msgList = message.split()
Lang = msgList[0]
del msgList[0]
seperator=" "
argstr = converttostr(input_seq=msgList, seperator=seperator)
print(Lang)
print(argstr)
translate1 = translate(argstr, Lang, "auto")
print(translate1)
I've tried just adding in static strings instead of splitting up arguments from another library and same error.
Anyone have any solution?
from mtranslate import translate
x = message_text
def main():
to_translate = x
x1 =(translate(to_translate))
x2 =(translate(to_translate, 'ar'))
x = x1 + " " + x2
if name == 'main':
main()
Hi, i've tried the python script and it is still working pretty well.
Is it possible to send POST requests to translate longer text?
see:
soimort/translate-shell#30
https://www.filosophy.org/post/36/crossdomain_post_requests_to_google_translate_v2/
Hi, is there any way to upgrade MTranslate for using Google API codes (https://cloud.google.com/translate/docs/auth#using_an_api_key)? For example, Because the base link is a little bit different with the primary base link in your code, I'm not sure if I change the base link what will happen? Google API's base link is https://translation.googleapis.com/language/translate/v2?key=YOUR_API_KEY. Do you have any idea? Thanks.
After 266 translation calls (in a for-loop) I get always the following error (it's always exactly 266). Do you know why?
Traceback (most recent call last):
File "/Users/username/PycharmProjects/Translation/GoogleTranslator.py", line 52, in <module>
review_trans = translate(review, 'en')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mtranslate/core.py", line 70, in translate
page = urllib.request.urlopen(request).read().decode("utf-8")
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 472, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 582, in http_response
'http', request, response, code, msg, hdrs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 510, in error
return self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 444, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 590, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
I am having a http error 400 while I'm trying to use it for translating a big .csv archive in google colab.
Google changed it's parameters and the result page sometimes looks different. The following changes are necessary:
1.) ht -> tl
base_link = "http://translate.google.com/m?tl=%s&sl=%s&q=%s"
expr = r'(?s)class="(?:t0|result-container)">(.*?)<'
Not sure if someone is still monitoring this project, but I'm getting the following error when using the translate option
<urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
Eventually works after trying a few more times and finishes successfully, but why is failing when my machine is online, is this hitting some sort of limit? any options around that?
Thanks.
File "/opt/virtualenvs/ros/local/lib/python2.7/site-packages/mtranslate/core.py", line 72, in translate
to_translate = urllib.quote_plus(to_translate)
File "/usr/lib/python2.7/urllib.py", line 1299, in quote_plus
s = quote(s, safe + ' ')
File "/usr/lib/python2.7/urllib.py", line 1294, in quote
return ''.join(map(quoter, s))
KeyError: u'\xe8'
I think this because I need to use unicode.
It's possible to use unicode?
Hi,
Any idea, why am I getting error 503 on my vps server as well as on my openshift account? On localhost it works fine.
Is this library legal to use?
I have to use proxy to cross over firewall to visit Google services.
Could you add proxy just like that in goslate
https://pypi.python.org/pypi/goslate
hey,
is there a way to convert this repository to a single ipynb file...
Hi, when i'm translating text, i'm getting my text and ", how to fix this?
It was working very well until recently, then it stopped translating when I checked today.
I donʻt think this is my IP blocked because I did not use it that much.
Does not show any warning/error message, just returns an empty string.
from mtranslate import translate
text = "Tu n'es pas un peroquet."
text_trans = translate(text, 'en')
print(text_trans)
Output:
You're not a parrot.
Is there a way to overcome this problem?
First, I appreciate the author and contributors for the great and cool work done here!
Out of a curious experiment, I tried to translate srt file (Movie subtitle file). Tried to translate English to Tamil
It is expected that the google translate will support the input up to 5000 characters, but the library could be
Now the library is translating up to characters 5000 but if we tried to run more than 5000 (Even 5001), it returns None
I can handle the limitations as per my requirement locally, but I am just notifying here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.