Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -65,14 +65,15 @@ def translate(text,lang):
|
|
65 |
content = resp.content
|
66 |
html = fromstring(content)
|
67 |
|
68 |
-
#src = html.xpath('//pre[@data-placeholder="Enter text"]/textarea')[0].text.strip()
|
69 |
-
|
70 |
translated = text
|
71 |
|
72 |
-
try:
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
translated = rslt
|
77 |
except:
|
78 |
raise Exception("Translation Error!")
|
|
|
65 |
content = resp.content
|
66 |
html = fromstring(content)
|
67 |
|
|
|
|
|
68 |
translated = text
|
69 |
|
70 |
+
try:
|
71 |
+
src_lang = html.xpath('//span[@class="source-language"]/span')[0].text_content().strip()
|
72 |
+
trgt_lang = html.xpath('//span[@class="target-language"]')[0].text_content().strip()
|
73 |
+
src_text = html.xpath('//pre[@id="tw-source-text"]/span')[0].text_content().strip()
|
74 |
+
trgt_text = html.xpath('//pre[@id="tw-target-text"]/span')[0].text_content().strip()
|
75 |
+
|
76 |
+
if trgt_lang.lower() == lang.lower():
|
77 |
translated = rslt
|
78 |
except:
|
79 |
raise Exception("Translation Error!")
|