Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -54,8 +54,8 @@ def translate(text,lang):
|
|
54 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15',
|
55 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
56 |
]
|
57 |
-
query_text = f'
|
58 |
-
url = f'
|
59 |
|
60 |
print(url)
|
61 |
|
@@ -80,7 +80,7 @@ def translate(text,lang):
|
|
80 |
if trgt_lang == lang:
|
81 |
translated = trgt_text
|
82 |
except:
|
83 |
-
raise
|
84 |
|
85 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
86 |
print(ret)
|
|
|
54 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15',
|
55 |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15'
|
56 |
]
|
57 |
+
query_text = f'Please translate {text} into {lang}'
|
58 |
+
url = f'https://www.google.com/search?q={query_text}'
|
59 |
|
60 |
print(url)
|
61 |
|
|
|
80 |
if trgt_lang == lang:
|
81 |
translated = trgt_text
|
82 |
except:
|
83 |
+
raise print(f'Warning: Could not translate "{text}" into {lang}!')
|
84 |
|
85 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
86 |
print(ret)
|