'''
Требуется python 3.11.9
https://www.python.org/ftp/python/3.11.9/
https://www.argosopentech.com/argospm/index/
https://github.com/argosopentech/argos-translate
py -3.11 -m pip install argostranslate
py -3.11 main.py "translate-en_ru-1_9.argosmodel" "Learn English online and improve your skills through our high-quality courses and resources. Everything you find here has been specially created by the British"
'''
import sys, os, argostranslate.package, argostranslate.translate
model = sys.argv[1] if len(sys.argv) > 1 else ''
text = sys.argv[2] if len(sys.argv) > 2 else ''
if not os.path.isfile(model):
print(f'Файл не найден: {model}')
sys.exit()
argostranslate.package.install_from_path(model)
installed_languages = argostranslate.translate.load_installed_languages()
from_lang = next(filter(lambda x: x.code == "en", installed_languages), None)
to_lang = next(filter(lambda x: x.code == "ru", installed_languages), None)
if not from_lang or not to_lang:
print('Нужные языки не установлены')
sys.exit()
translation = from_lang.get_translation(to_lang)
result = translation.translate(text)
sys.stdout.buffer.write(result.encode("utf-8", errors="replace"))
*текст* - жирный,
~текст~ - курсивный,
-текст- - _текст_ - подчеркнутый