UlionTse / translators

🌏🌍🌎Translators🌎🌍🌏 is a library that aims to bring free, multiple, enjoyable translations to individuals and students in Python. Translators是一个旨在用Python为个人和学生带来免费、多样、愉快翻译的库。
https://pypi.org/project/translators/
GNU General Public License v3.0
1.78k stars 196 forks source link

[Bug]: Google doesn't give the correct translation #163

Open bropines opened 1 month ago

bropines commented 1 month ago

Debug Tips

What happened?

For some reason, in response to the request, only one part of the text (brackets) is received, and the second is lost


Original text: し 、 従いまひゅ 宮司 様……

Translated text:
[bing] и Священник Храма......
[google] Итак, Маху Мияши ...
[yandex] Ошибка при переводе: Unsupported from_language[ja] in ['az', 'be', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'hr', 'hu', 'hy', 'it', 'lt', 'lv', 'mk', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sv', 'tr', 'uk', 'zh'].
[alibaba] И следуй за Махи Мияджи...
 python .\test.py

Original text: (kudze sara) し 、 従いまひゅ 宮司 様……

Translated text:
[bing] (кудзе сара) и г-н Миядзи......
[google] (Кудзе Сара)
[yandex] Ошибка при переводе: Unsupported from_language[ja] in ['az', 'be', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'hr', 'hu', 'hy', 'it', 'lt', 'lv', 'mk', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sv', 'tr', 'uk', 'zh'].
[alibaba] (Кудзе Сара)

APP Version

5.9.3 (default)

Python Version

3.10

Runtime Environment

Windows

Country/Region

Russia

Relevant log output

No response

Screenshots

No response

Code of Conduct

bropines commented 1 month ago

And also, Yandex can translate Japanese, but apparently you haven’t updated this in the code

UlionTse commented 2 weeks ago

@bropines Sorry for long time.

  1. About Google: Can you provide Google's wrong result and web correct result correspondingly?
# My judgment:
if translators's google result == google web result:
    return True

# Your judgment:
if translators's google result == My idea result:
    return True

Of course, Maybe this: #35 Second lost: Maybe your request is so fast that you could not recieve complete result. (Imagine a rendering of a web page)

  1. About Yandex: You are right, next version package will be updated. But you can do this temporarily:
    
    import translators as ts

print(ts.translate_text(query_text='你好', translator='yandex')) ts.server._yandex.language_map.update({'ja': ['ru']}) # add lang_pair you want print(ts.translate_text(query_text='こんにちは', translator='yandex', from_language='ja', to_language='ru'))

UlionTse commented 2 weeks ago

Imagine typing a sentence in real time in a web page translation window. How many times does the request result refresh behind it? If the input generated a large number of translation requests queue in a short time, if I were a developer, I would design a sliding window such as 24ms, I only handle the latest request in the sliding window, so as to basically meet the effect of real-time translation of the web page. As you asked, if your requests are too fast and multiple requests are planned into a sliding window, will the results be lost?

bropines commented 2 weeks ago

That is, I make requests so quickly that the second part of the translation simply doesn’t load for me... Right?

And essentially I can just make the wait a little longer when receiving a transfer. I wish I knew how....