Skip to content

Commit

Permalink
fix ts init issue
Browse files Browse the repository at this point in the history
  • Loading branch information
versun authored Aug 21, 2024
1 parent 324dee5 commit 7313e2e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion translator/models/google_translate_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Meta:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
import translators as ts
self.ts = ts

def validate(self) -> bool:
results = self.translate("hi", "Chinese Simplified", validate=True)
Expand All @@ -67,7 +68,7 @@ def translate(self, text: str, target_language: str, validate:bool=False, **kwar
# resp = httpx.get(self.base_url, params=params, timeout=10, proxy=self.proxy)
# resp.raise_for_status()
# resp_json = resp.json()
results = ts.translate_text(text, to_language=target_language, translator="google", reset_host_url=self.base_url, proxies=self.proxy)
results = self.ts.translate_text(text, to_language=target_language, translator="google", reset_host_url=self.base_url, proxies=self.proxy)
if results:
translated_text = results
except Exception as e:
Expand Down

0 comments on commit 7313e2e

Please sign in to comment.