Skip to content

Commit

Permalink
Translate fuzzy entries
Browse files Browse the repository at this point in the history
  • Loading branch information
BillHuang2001 committed Jan 19, 2025
1 parent db31e2a commit 4ecb2d9
Show file tree
Hide file tree
Showing 2 changed files with 1,754 additions and 1,969 deletions.
6 changes: 4 additions & 2 deletions docs/machine_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _one_restful_request(self, query):
}
for retry in range(self.num_retry):
try:
response = httpx.post(self.url, headers=headers, json=data)
response = httpx.post(self.url, headers=headers, json=data, timeout=30.0)
json_response = response.json()
except Exception:
import traceback
Expand Down Expand Up @@ -102,7 +102,7 @@ def query(self, query):
po = polib.pofile("docs/source/locale/zh/LC_MESSAGES/docs.po")
try:
for entry in po:
if entry.msgstr:
if entry.msgstr and not entry.fuzzy:
continue

if pattern.match(entry.msgid) or entry.msgid.startswith("<svg"):
Expand All @@ -115,6 +115,8 @@ def query(self, query):
tranlated = tgi.query(query)
logging.info("\n")
entry.msgstr = tranlated
if entry.fuzzy:
entry.flags.remove("fuzzy")
except KeyboardInterrupt:
logging.warning("Interrupted by user.")
except Exception as e:
Expand Down
Loading

0 comments on commit 4ecb2d9

Please sign in to comment.