5
I am trying to create a Python application where I need to translate some texts, and to perform such a task, I am using the API googletrans
.
text = 'Back in the day people used to go to many different places to buy the things they needed at home. They used to go to the butcher for meat and chicken, to the fruit market for fresh fruit, and to the bakery for bread. Nowadays, most people just go to one place to get everything they need. They can buy fruit, vegetables, bread, meat, milk and frozen foods at their local supermarket.'
translator = Translator()
result = translator.translate(text, "pt", "en").text
print("Original:", text)
print("-----------------")
print("Tradução:", result)
The problem is that almost all translations of the texts I post have problems (problems that do not happen when translating the same text in Google Translate by browser).
See below the output of the above code:
Original: Back in the day people used to go to Many Different Places to buy the Things they needed at home. They used to go to the Butcher for Meat and Chicken, to the Fruit market for Fresh Fruit, and to the Bakery for Bread. Nowadays, Most people just go to one place to get Everything they need. They can buy Fruit, vegetables, Bread, Meat, milk and Frozen Foods at their local.
Translation: Back in the day people used to go to many different places to buy the things they needed at home. They used to go to the meat and chicken butcher, to the fruit market for fresh fruit, and even to the bread bakery. Nowadays, most people just go to a place to get everything they need. They can buy fruit, vegetables, bread, meat, milk and frozen foods at their local supermarket.
Below is the translating made by Google Translator via browser:
In the past, people used to go to many different places to buy what they needed at home. They used to go to the butcher shop to meat and chicken, the fresh fruit market and the bakery for bread. Nowadays, most people go to a place to get everything you need. They can buy fruits, vegetables, bread, meat, Frozen milk and food at the local supermarket.
Am I doing something wrong? How can I do the googletrans
translate exactly like Google Browser Translator?
Details of the environment:
- Python 3.7.6
- googletrans: 3.0.0
- Windows 7 (x64)
It really seems to be a problem with the library, you can see here and here
– sant0will
If that’s the case, you can use the Google Cloud lib
– sant0will
You need to pay or create an account to use this Google Cloud ?
– JeanExtreme002
No need to pay, you only need a Google account. You can follow this Basic guide
– sant0will
Which version of Python3? Which version of googletrans? Which operating system?
– Guilherme Nascimento
@Guilhermenascimento answered in the issue of the question.
– JeanExtreme002
@Jeanextreme002 of course they are necessary, to configure the environment exactly or close to yours to then be able to determine if it is VERSION failure that you are using from LIB or is failure based on something of the operating system (which indicates bug in lib as well) or if it is fault/conflict in the python version (which indicates bug in lib as well) ... This is always necessary, if it was your open source, you really don’t need it, but the problem is in a third party lib.
– Guilherme Nascimento
I edited the question, because space is not to question how you think a question to be or not to be formulated, space is to explain your problem and inform the environment you use, also do not use tags that have no problem with the question, the tag [tag:api] is not to be used when the problem is about third party libs. If you disagree with the need to add configs and versions of your environment you can take the query to https://pt.meta.stackoverflow.com/ - I edited the question to improve the text and details and reopen it.
– Guilherme Nascimento