nidhal baccouri
commited on
Commit
·
1c48989
1
Parent(s):
b9e395b
fixed bug in dutch translation using google trans
Browse files
deep_translator/google_trans.py
CHANGED
@@ -105,8 +105,12 @@ class GoogleTranslator(BaseTranslator):
|
|
105 |
element = soup.find(self._element_tag, self._alt_element_query)
|
106 |
if not element:
|
107 |
raise TranslationNotFound(text)
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
110 |
|
111 |
def translate_file(self, path, **kwargs):
|
112 |
"""
|
@@ -167,7 +171,7 @@ class GoogleTranslator(BaseTranslator):
|
|
167 |
return arr
|
168 |
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
105 |
element = soup.find(self._element_tag, self._alt_element_query)
|
106 |
if not element:
|
107 |
raise TranslationNotFound(text)
|
108 |
+
if element.get_text(strip=True) == text:
|
109 |
+
self._url_params["tl"] = self._target
|
110 |
+
del self._url_params["hl"]
|
111 |
+
return self.translate(text)
|
112 |
+
else:
|
113 |
+
return element.get_text(strip=True)
|
114 |
|
115 |
def translate_file(self, path, **kwargs):
|
116 |
"""
|
|
|
171 |
return arr
|
172 |
|
173 |
|
174 |
+
if __name__ == '__main__':
|
175 |
+
|
176 |
+
txt =GoogleTranslator(source='en', target='nl').translate('why not Dutch') # GoogleTranslator(source='hindi', target='en').translate(text="ghar jaana hai")
|
177 |
+
print("text: ", txt)
|