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.62k stars 189 forks source link

[Bug]: "The `query_text` can't be empty!" in translate_html #141

Closed Cabu closed 11 months ago

Cabu commented 11 months ago

Debug Tips

What happened?

When translating an HTML content with translate_html, I get a "The query_text can't be empty!" because the pattern find empty string even if the HTML I send doesn't contain any.

replacing in server.py the line 5326

sentence_list = list(set(pattern.findall(html_text)))

by

sentence_list = list(text for text in set(pattern.findall(html_text)) if text)

Solve my problem and as a side effect solve the TODO

APP Version

5.8.3

Python Version

3.11

Runtime Environment

Linux CentOS (Default)

Country/Region

Belgium

Relevant log output

No response

Screenshots

No response

Code of Conduct

UlionTse commented 11 months ago

@Cabu https://github.com/UlionTse/translators/issues/130#issuecomment-1562749253