Skip to content

Commit

Permalink
fixed bug in google_trans
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhaloff committed Feb 12, 2021
1 parent 21923f3 commit 79bdd3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deep_translator/google_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def translate(self, text, **kwargs):
element = soup.find(self._element_tag, self._alt_element_query)
if not element:
raise TranslationNotFound(text)
if element.get_text(strip=True) == text:
if element.get_text(strip=True) == text.strip() and text.strip().replace(' ', '').isalpha():
self._url_params["tl"] = self._target
del self._url_params["hl"]
return self.translate(text)
Expand Down Expand Up @@ -173,5 +173,5 @@ def translate_batch(self, batch=None):

if __name__ == '__main__':

txt =GoogleTranslator(source='zh', target='en').translate('好的') # GoogleTranslator(source='hindi', target='en').translate(text="ghar jaana hai")
txt =GoogleTranslator(source='en', target='nl').translate('why not dutch') # GoogleTranslator(source='hindi', target='en').translate(text="ghar jaana hai")
print("text: ", txt)

0 comments on commit 79bdd3a

Please # to comment.