From 585f6eb41b2ce109e139f267535ba46c835bfaad Mon Sep 17 00:00:00 2001 From: "|| Prof. - Xadk3!" Date: Thu, 4 May 2023 05:54:48 +0000 Subject: [PATCH] =?UTF-8?q?@cmd+=E0=A4=86=E0=A4=B0.=E0=A4=8F=E0=A4=AB.?= =?UTF-8?q?=E0=A4=B8.=E0=A4=B8.=E0=A4=B8=E0=A5=80=20=E0=A5=AE=E0=A5=A8?= =?UTF-8?q?=E0=A5=A8+nips-=E0=A5=A7=E0=A5=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translate.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/translate.py b/translate.py index 6c7b75f..e9a7bf1 100755 --- a/translate.py +++ b/translate.py @@ -3,8 +3,38 @@ import readline # import urllib.parse from selenium import webdriver +from sys import argv + +tr_lang = 'ne'; + +class ArguMenToR: + def __init__(self, *args): + if 'help' in ' '.join(args[0]): + print(f''' +{argv[0]} [--lang=ne] +Choices: + Nepali: ne + Japanese: ja + Chinese: zh-(TW/CN) + English: en + Hindi: hi + ''') + self.argv = list(args)[0] + self.param = 'lang' + self.parse() + + def parse(self): + global tr_lang + spaced_args = ' '.join(self.argv[1:]) + if spaced_args.startswith('-'): + if '=' in spaced_args: + tr_lang = spaced_args.split('=')[1] + else: + tr_lang = spaced_args browser = webdriver.Firefox() +ArguMenToR(argv) + _lang_conf = { 'nepali': 'ne', 'english': 'en', @@ -18,8 +48,8 @@ _TRP_CONSTRUCT = "https://DOMAIN.translate.goog/PATH?_x_tr_sl=auto&_x_tr_tl=TRL" # TODO: URL-parsing url = input("Enter URL you wish to translate: ") -_lang = _lang_conf['nepali'] -_TRP_CONSTRUCT = _TRP_CONSTRUCT.replace('TRL', _lang) +# _lang = _lang_conf['nepali'] +_TRP_CONSTRUCT = _TRP_CONSTRUCT.replace('TRL', tr_lang) remote_domain = url.split('://')[1].split('/')[0] #print('-'.join(remote_domain.split('.')[1:]))