~metalune/simplytranslate-devel

cli: Add support for DeepL and ICIBA engines v1 PROPOSED

fattalion: 1
 Add support for DeepL and ICIBA engines

 1 files changed, 21 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~metalune/simplytranslate-devel/patches/27058/mbox | git am -3
Learn more about email & git

[PATCH cli] Add support for DeepL and ICIBA engines Export this patch

Yes, I checked, it's iCIBA with a lowercase initial i.

Also formatted the file using `black`.
---
 main.py | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/main.py b/main.py
index f1922e4..854e595 100755
--- a/main.py
+++ b/main.py
@@ -6,6 +6,8 @@ from urllib.parse import urlencode

from simplytranslate_engines.libretranslate import LibreTranslateEngine
from simplytranslate_engines.googletranslate import GoogleTranslateEngine
from simplytranslate_engines.icibatranslate import IcibaTranslateEngine
from simplytranslate_engines.deepl import DeeplEngine
from simplytranslate_engines.utils import to_lang_code

############################
@@ -19,7 +21,7 @@ parser.add_argument("text", metavar="TEXT", nargs="+", help="The text to transla
parser.add_argument(
    "-e",
    "--engine",
    choices=("google", "libre"),
    choices=("google", "libre", "iciba", "deepl"),
    default="google",
    help="Translation engine to use",
)
@@ -37,7 +39,14 @@ parser.add_argument(

parser.add_argument("-f", "--from", default="auto", help="Language to translate from")
parser.add_argument("-t", "--to", default="en", help="Language to translate to")
parser.add_argument("-p", "--print", default=False, type=bool, action=argparse.BooleanOptionalAction, help="Toggle wether or not to print a shareable link, only works if --online is provided.")
parser.add_argument(
    "-p",
    "--print",
    default=False,
    type=bool,
    action=argparse.BooleanOptionalAction,
    help="Toggle wether or not to print a shareable link, only works if --online is provided.",
)

parser.add_argument(
    "-d",
@@ -140,6 +149,16 @@ else:
            parser.error("You can't set instance for Google Translate")

        engine = GoogleTranslateEngine()
    elif engine_name == "iciba":
        if instance is not None:
            parser.error("You can't set instance for iCIBA")

        engine = IcibaTranslateEngine()
    elif engine_name == "deepl":
        if instance is not None:
            parser.error("You can't set instance for DeepL")

        engine = DeeplEngine()

    from_language = to_lang_code(from_language, engine)
    to_language = to_lang_code(to_language, engine)
@@ -162,4 +181,3 @@ else:

    if online and print_link:
        print(link)

-- 
2.34.1