Open re7gog opened 2 years ago
I'm thinking of using the implementation from this server in Yandex translator. I use it myself and it works great. https://github.com/FOSWLY/translate-backend
I also have a question. Why not divide all translators into modules? As I understand it, they are loaded from one file, which looks a bit like a crutch.
@UlionTse ?
@bropines Sorry, bro. I saw it before, but forgot to reply after reading other questions. Thank you for the reference. Due to work reasons, the next update will be during the International Labor Day.
I also have a question. Why not divide all translators into modules? As I understand it, they are loaded from one file, which looks a bit like a crutch.
It's a personal hobby. Since around 40 separate files makes the code very boring and garbage bin-like, I prefer to use classes and inheritance to build complex code and easily count how many lines of code the project has.
@bropines Sorry, bro. I saw it before, but forgot to reply after reading other questions. Thank you for the reference. Due to work reasons, the next update will be during the International Labor Day.
You can take your time and spend the holidays with your loved ones.
It's a personal hobby. Since around 40 separate files makes the code very boring and garbage bin-like, I prefer to use classes and inheritance to build complex code and easily count how many lines of code the project has.
Well, basically your job, do it the way it's convenient. I'm just used to projects where everything is divided into 1000 million modules. Nothing, and I figured it out in general. Thanks for the work.
Respect and Thanks.
@bropines Bro, please pip install --upgrade translators==5.9.2
Yes, I saw it, thank you. I will check it Through my translator program and we can close the issue.
@UlionTse
There's a problem here. He says that there is no Japanese, but when I run the API of the library that I downloaded earlier, it translates from Japanese without any questions. At the same time, if I write auto
it translates, if I write the language code ja
it gives an error.
JA
import translators as ts
# Просмотр доступных переводчиков
print(ts.translators_pool)
# Пример использования функции translate_text с Яндекс Переводчиком
translated_text = ts.translate_text(
query_text="もっと球を見る意識が大事だ! ! あとはできているの. . . ",
translator='yandex',
from_language='ja',
to_language='ru'
)
print(translated_text)
log
╰─ python .\trasnasa.py
['alibaba', 'apertium', 'argos', 'baidu', 'bing', 'caiyun', 'cloudTranslation', 'deepl', 'elia', 'google', 'hujiang', 'iciba', 'iflytek', 'iflyrec', 'itranslate', 'judic', 'languageWire', 'lingvanex', 'niutrans', 'mglip', 'mirai', 'modernMt', 'myMemory', 'papago', 'qqFanyi', 'qqTranSmart', 'reverso', 'sogou', 'sysTran', 'tilde', 'translateCom', 'translateMe', 'utibet', 'volcEngine', 'yandex', 'yeekit', 'youdao']
Traceback (most recent call last):
File "D:\Рабочий стол\Рабочий стол Clear\trasnasa.py", line 7, in <module>
translated_text = ts.translate_text(
File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 5555, in translate_text
return self.translators_dict[translator](query_text=query_text, from_language=from_language, to_language=to_language, **kwargs)
File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 117, in _wrapper
return func(*args, **kwargs)
File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 288, in _wrapper
return func(*args, **{**kwargs, **{'query_text': query_text}})
File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 2387, in yandex_api
from_language, to_language = self.check_language(from_language, to_language, self.language_map, output_zh=self.output_zh)
File "G:\Ballon-translator-portable-main\venv\lib\site-packages\translators\server.py", line 194, in check_language
raise TranslatorError('Unsupported from_language[{}] in {}.'.format(from_language, sorted(language_map.keys())))
translators.server.TranslatorError: 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'].
AUTO
import translators as ts
# Просмотр доступных переводчиков
print(ts.translators_pool)
# Пример использования функции translate_text с Яндекс Переводчиком
translated_text = ts.translate_text(
query_text="もっと球を見る意識が大事だ! ! あとはできているの. . . ",
translator='yandex',
from_language='auto',
to_language='ru'
)
print(translated_text)
log
╰─ python .\trasnasa.py
['alibaba', 'apertium', 'argos', 'baidu', 'bing', 'caiyun', 'cloudTranslation', 'deepl', 'elia', 'google', 'hujiang', 'iciba', 'iflytek', 'iflyrec', 'itranslate', 'judic', 'languageWire', 'lingvanex', 'niutrans', 'mglip', 'mirai', 'modernMt', 'myMemory', 'papago', 'qqFanyi', 'qqTranSmart', 'reverso', 'sogou', 'sysTran', 'tilde', 'translateCom', 'translateMe', 'utibet', 'volcEngine', 'yandex', 'yeekit', 'youdao']
важно осознавать, что нужно чаще видеть мяч! ! Остальное сделано. . .
@bropines I know this. In the reference code you provided, there are indeed few types of acquisition languages involved. Therefore, it is recommended to use auto. I didn't see Chinese in language_map, but Chinese can also be used. https://github.com/UlionTse/translators/blob/13564ea8c7f6844aeabab169f4ac87f396025b19/translators/server.py#L2341
maybe you should add a message like "try auto" in response to a language that does not exist?
@bropines I know this. In the reference code you provided, there are indeed few types of acquisition languages involved. Therefore, it is recommended to use auto. I didn't see Chinese in language_map, but Chinese can also be used.
@UlionTse Also, there is a problem with deepl, which seems to have already been fixed in deeplx. Error when translating text: 429 Client Error: for url: https://www2.deepl.com/jsonrpc?method=LMT_split_text
Here is my JS code that roughly uses the same logic. https://github.com/bropines/Deeplx-vercel/blob/main/translate.js
Yandex translate doesn't work at all (google for example is fine)
Code: import translators print(translators.yandex("Привет"))
Output: Using state Moscow server backend. Traceback (most recent call last): File "D:\Code\pythonProject\main.py", line 2, in
print(translators.yandex("Привет"))
File "D:\Code\pythonProject\venv\lib\site-packages\translators\apis.py", line 1418, in yandex_api
r.raise_for_status()
File "D:\Code\pythonProject\venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://translate.yandex.com/