mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
fix: #279
This commit is contained in:
parent
1a0bd42259
commit
a599ba7eee
@ -32,6 +32,12 @@ class Caiyun(Base):
|
|||||||
|
|
||||||
def translate(self, text):
|
def translate(self, text):
|
||||||
print(text)
|
print(text)
|
||||||
|
# for caiyun translate src issue #279
|
||||||
|
text_list = text.splitlines()
|
||||||
|
num = None
|
||||||
|
if len(text_list) > 1:
|
||||||
|
if text_list[0].isdigit():
|
||||||
|
num = text_list[0]
|
||||||
payload = {
|
payload = {
|
||||||
"source": text,
|
"source": text,
|
||||||
"trans_type": self.translate_type,
|
"trans_type": self.translate_type,
|
||||||
@ -60,4 +66,7 @@ class Caiyun(Base):
|
|||||||
t_text = response.json()["target"]
|
t_text = response.json()["target"]
|
||||||
|
|
||||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||||
|
# for issue #279
|
||||||
|
if num:
|
||||||
|
t_text = str(num) + "\n" + t_text
|
||||||
return t_text
|
return t_text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user