commit 4a78a0c668c764df6e24ce923243b594aea830b3 from: Aleksey Ryndin date: Thu Jul 06 10:04:41 2023 UTC Add: translate using https://translate.foxhaven.cyou/ commit - e662650f7b8e4d96483fbcf3d72f1b6c44e3a5af commit + 4a78a0c668c764df6e24ce923243b594aea830b3 blob - /dev/null blob + 05367634ae1a32d33829941860e9019d300ec5b6 (mode 755) --- /dev/null +++ 2ru @@ -0,0 +1,26 @@ +#!/usr/local/bin/python3 +# -*- coding: utf-8 -*- +import sys +import requests + + +def _post_translate_auto_ru(q): + r = requests.post("https://translate.foxhaven.cyou/translate", + json=dict(q=q, source="auto", target="ru", format="text", api_key=""), + headers={"Content-Type": "application/json"}, + timeout=30) + r.raise_for_status() + return r.json()["translatedText"] + + +if len(sys.argv) > 1: + print(_post_translate_auto_ru(" ".join(sys.argv[1:]))) +else: + while True: + q = input(">>> ").strip() + if not q: + continue + try: + print(_post_translate_auto_ru(q)) + except Exception as error: + print("(!) exception: %s", error)