@cmd+आर.एफ.स.स.सी ८२२+nips-१३
This commit is contained in:
parent
0c708b3ccc
commit
585f6eb41b
1 changed files with 32 additions and 2 deletions
34
translate.py
34
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:]))
|
||||
|
|
Loading…
Reference in a new issue