From 49106b601a7268edf78844355a59cb6886deb33d Mon Sep 17 00:00:00 2001 From: "|| Prof. - Xadk3!" Date: Mon, 1 May 2023 08:22:59 +0000 Subject: [PATCH] =?UTF-8?q?@cmt++RFC=E0=A5=AE=E0=A5=A8=E0=A5=A8+nips-?= =?UTF-8?q?=E0=A5=A7=E0=A5=A9++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translate.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/translate.py b/translate.py index d853d46..1d40d34 100755 --- a/translate.py +++ b/translate.py @@ -4,7 +4,16 @@ import readline from selenium import webdriver browser = webdriver.Firefox() -TRP_CONSTRUCT = "https://DOMAIN.translate.goog/PATH/?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp" +_lang_conf = { + 'nepali': 'ne', + 'english': 'en', + 'japanese': 'ja', + 'chinese-tradional': 'zh-TW', + 'chinese-simplified': 'zh-CN', + 'hindi': 'hi' +}; TRP_CONSTRUCT = "https://DOMAIN.translate.goog/PATH/?_x_tr_sl=auto&_x_tr_tl=[TRL]&_x_tr_hl=en-US&_x_tr_pto=wapp" +neTRP_CONSTRUCT = TRP_CONSTRUCT.replace('[TRL]', 'ne') +enTRP_CONSTRUCT = TRP_CONSTRUCT.replace('[TRL]', 'en') # yet another globals object ! url = input("Enter URL you wish to translate: ") remote_domain = url.split('://')[1].split('/')[0] @@ -13,10 +22,10 @@ rDUri = remote_domain.replace('.', '-') if '?' in remote_path: remote_path = remote_path.split('?')[0] remote_URL_query = ''.join(url.split('?')[1:]) - rUrl = TRP_CONSTRUCT.replace('DOMAIN', rDUri).replace('PATH', remote_path) + '&' + remote_URL_query + rUrl = neTRP_CONSTRUCT.replace('DOMAIN', rDUri).replace('PATH', remote_path) + '&' + remote_URL_query else: - rUrl = TRP_CONSTRUCT.replace('DOMAIN', rDUri).replace('PATH', remote_path) + rUrl = neTRP_CONSTRUCT.replace('DOMAIN', rDUri).replace('PATH', remote_path) -print("Executing :" + rUrl + " \nwithin DOM.") +print("Executing: " + rUrl + " \n\twithin #DOM .") browser.get(rUrl) browser.execute_script('''document.querySelector('iframe').style.display = "none";document.querySelector('iframe').remove()''')