Saravananslb / py-googletranslation

pygoogletranslation: Free and Unlimited Google translate API for Python. Translates totally free of charge.
https://saravananslb.github.io/py-googletranslation/
MIT License
156 stars 40 forks source link

Translation stopping at japanese dot (。) #20

Closed finia2NA closed 3 years ago

finia2NA commented 3 years ago

Describe the bug The Translation of text seems to stop at a japanese dot (。), which is used frequently to mark the end of a sentence. This is not the case on the google translate website, or when using regular dots.

To Reproduce The following exerpt is from a session with python 3.8.5 and pygoogletranslation 2.0.5

❯ python
Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> from pygoogletranslation import Translator
>>> t = Translator()

>>> t.translate("おはようございます。私の名前はカンナです。").text
'Good morning.'

>>> t.translate("おはようございます.私の名前はカンナです.").text
'Good morning. My name is Kanna.'

As can be seen, when using japanese dots, only the first sentence "good morning" is translated. The second sentence "My name is Kanna" is not. This is not the case when using english dots.

Expected behavior The whole text should be translated, like it was when using english dots.

Desktop (please complete the following information):

finia2NA commented 3 years ago

I have begun working on this myself. Not entirely sure how to do this though. It seems google sends back parts that would make up the correct translation, but they are not being assembled correctly. My quick and dirty fix would be to just replace the 。 with . before sending text away.

On my branch, I clarified what is needed to run and test the program, and created a Pipfile for convenience. I also deleted the pycache in the pygoogletranslation folder. And I created the outline for a test for the punctuation problem.

Replacing a japanese point with an english one works in the sense that the whole sentence gets translated, but the result is not the same as on the google translate site.

finia2NA commented 3 years ago

Duplicate of #12