This commit is contained in:
恍兮惚兮 2024-05-25 01:37:53 +08:00
parent 82bf1feaa6
commit f104630ccb
21 changed files with 87 additions and 28 deletions

View File

@ -294,12 +294,22 @@ class AnkiWindow(QWidget):
remarks = self.remarks.toPlainText()
example = self.example.toPlainText()
if globalconfig["ankiconnect"]["boldword"]:
if self.example.hiras is None:
self.example.hiras = gobject.baseobject.translation_ui.parsehira(example)
collect = []
for hira in self.example.hiras:
if hira["orig"] == word or hira.get("origorig", None) == word:
collect.append(f'<b>{hira["orig"]}</b>')
else:
collect.append(hira["orig"])
example = "".join(collect)
ruby = self.ruby
fields = {
"word": word,
"rubytext": ruby,
"explain": explain,
"example_sentence": example,
"example_sentence": example.replace("\n", "<br>"),
"remarks": remarks,
}
return fields
@ -401,6 +411,10 @@ class AnkiWindow(QWidget):
_TR("自动截图"),
getsimpleswitch(globalconfig["ankiconnect"], "autocrop"),
)
layout.addRow(
_TR("例句中加粗单词"),
getsimpleswitch(globalconfig["ankiconnect"], "boldword"),
)
layout.addRow(
_TR("录音时模拟按键_1"),
@ -461,6 +475,12 @@ class AnkiWindow(QWidget):
self.viewimagelabel = QLabel()
self.editpath.textChanged.connect(self.wrappedpixmap)
self.example = QPlainTextEdit()
self.example.hiras = None
def __():
self.example.hiras = None
self.example.textChanged.connect(__)
self.remarks = QPlainTextEdit()
recordbtn1 = statusbutton(icons=["fa.microphone", "fa.stop"], colors=[""])
recordbtn1.statuschanged1.connect(

View File

@ -149,10 +149,15 @@ class QUnFrameWindow(resizableframeless):
def parsehira(self, text):
hira = []
try:
if gobject.baseobject.hira_:
hira = gobject.baseobject.hira_.parseparse(text)
for i, _ in enumerate(text.split("\n")):
h = gobject.baseobject.hira_.parseparse(_)
if i:
hira += [{"orig": "\n", "hira": "\n"}]
hira += h
except:
print_exc()
return hira
@ -171,12 +176,7 @@ class QUnFrameWindow(resizableframeless):
return
text = self.cleartext(text)
if hira:
hiras = [self.parsehira(_) for _ in text.split("\n")]
hira = []
for i, _h in enumerate(hiras):
if i:
hira += [{"orig": "\n", "hira": "\n"}]
hira += _h
hira = self.parsehira(text)
else:
hira = []
self.translate_text.setnextfont(origin)

View File

@ -12,7 +12,11 @@
html = ''
if (ruby.length) {
for (i = 0; i < ruby.length; i++) {
html += ruby[i]['orig'] + '<rt>' + ruby[i]['hira'] + '</rt>';
html += ruby[i]['orig'];
if (ruby[i]['orig'] != ruby[i]['hira'])
html += '<rt>' + ruby[i]['hira'] + '</rt>';
else
html += '<rt></rt>';
}
html = '<ruby>' + html + '</ruby>'
document.getElementById('rubyword').innerHTML = html
@ -24,7 +28,7 @@
</script>
<div id="example_sentence" class="centerdiv example-div" onclick='playAudio("audio_sentence")'>
<div id="example_sentence" class="example-div" onclick='playAudio("audio_sentence")'>
{{example_sentence}}
</div>
<div id="image" class="centerdiv">

View File

@ -12,7 +12,11 @@
html = ''
if (ruby.length) {
for (i = 0; i < ruby.length; i++) {
html += ruby[i]['orig'] + '<rt>' + ruby[i]['hira'] + '</rt>';
html += ruby[i]['orig'];
if (ruby[i]['orig'] != ruby[i]['hira'])
html += '<rt>' + ruby[i]['hira'] + '</rt>';
else
html += '<rt></rt>';
}
html = '<ruby>' + html + '</ruby>'
document.getElementById('rubyword').innerHTML = html
@ -24,7 +28,7 @@
</script>
<div id="example_sentence" class="centerdiv example-div" onclick='playAudio("audio_sentence")'>
<div id="example_sentence" class="example-div" onclick='playAudio("audio_sentence")'>
{{example_sentence}}
</div>
<div id="image" class="centerdiv">

View File

@ -17,6 +17,7 @@
}
.example-div {
text-align: center;
font-family: BIZ UDGothic;
font-size: 24px;
text-align: center;

View File

@ -194,7 +194,8 @@
"keycode": 120
}
},
"autocrop": false
"autocrop": false,
"boldword": false
},
"imageformat": -1,
"ankiwindow": [

View File

@ -798,5 +798,7 @@
"对齐": "محاذاة",
"居左": "البقاء على اليسار",
"居右": "يعيش الحق",
"截图保存格式": "حفظ الشكل"
"截图保存格式": "حفظ الشكل",
"交流群": "مجموعة ميلان",
"例句中加粗单词": "على سبيل المثال كلمة جريئة"
}

View File

@ -798,5 +798,7 @@
"对齐": "對齊",
"居左": "居左",
"居右": "居右",
"截图保存格式": "截圖保存格式"
"截图保存格式": "截圖保存格式",
"交流群": "交流群",
"例句中加粗单词": "例句中加粗單詞"
}

View File

@ -798,5 +798,7 @@
"对齐": "alignment",
"居左": "be at the left side",
"居右": "be at the right",
"截图保存格式": "Screenshot Save Format"
"截图保存格式": "Screenshot Save Format",
"交流群": "Communication groups",
"例句中加粗单词": "Bold words in the example sentence"
}

View File

@ -798,5 +798,7 @@
"对齐": "Alinear",
"居左": "Ju Zuo",
"居右": "A la derecha",
"截图保存格式": "Formato de Guardar captura de pantalla"
"截图保存格式": "Formato de Guardar captura de pantalla",
"交流群": "Grupo de comunicación",
"例句中加粗单词": "Palabras en negrita en oraciones de ejemplo"
}

View File

@ -798,5 +798,7 @@
"对齐": "Alignement",
"居左": "Vivre à gauche",
"居右": "Vivre à droite",
"截图保存格式": "Format de sauvegarde des captures d'écran"
"截图保存格式": "Format de sauvegarde des captures d'écran",
"交流群": "Groupe d'échange",
"例句中加粗单词": "Mots épaissis dans une phrase d'exemple"
}

View File

@ -798,5 +798,7 @@
"对齐": "allineamento",
"居左": "essere sul lato sinistro",
"居右": "essere a destra",
"截图保存格式": "Schermata Salva formato"
"截图保存格式": "Schermata Salva formato",
"交流群": "Gruppi di comunicazione",
"例句中加粗单词": "Parole grasse nella frase di esempio"
}

View File

@ -798,5 +798,7 @@
"对齐": "配置",
"居左": "左に位置する",
"居右": "右に位置する",
"截图保存格式": "スクリーンショット保存形式"
"截图保存格式": "スクリーンショット保存形式",
"交流群": "こうりゅうぐん",
"例句中加粗单词": "例文中の太字単語"
}

View File

@ -798,5 +798,7 @@
"对齐": "정렬",
"居左": "왼쪽",
"居右": "오른쪽",
"截图保存格式": "캡처 저장 형식"
"截图保存格式": "캡처 저장 형식",
"交流群": "교류군",
"例句中加粗单词": "예문에 단어를 굵게 넣다"
}

View File

@ -798,5 +798,7 @@
"对齐": "wyrównanie",
"居左": "być po lewej stronie",
"居右": "bądź po prawej stronie",
"截图保存格式": "Zrzut ekranu Zapisz format"
"截图保存格式": "Zrzut ekranu Zapisz format",
"交流群": "Grupy ds. komunikacji",
"例句中加粗单词": "Pogrubione słowa w zdaniu przykładowym"
}

View File

@ -798,5 +798,7 @@
"对齐": "Выровнять",
"居左": "Цзяо",
"居右": "справа от дома",
"截图保存格式": "Формат сохранения снимков"
"截图保存格式": "Формат сохранения снимков",
"交流群": "Коммутаторная группа",
"例句中加粗单词": "Добавить слово в пример"
}

View File

@ -798,5 +798,7 @@
"对齐": "จัดตำแหน่ง",
"居左": "จู",
"居右": "จูขวา",
"截图保存格式": "รูปแบบการบันทึกภาพหน้าจอ"
"截图保存格式": "รูปแบบการบันทึกภาพหน้าจอ",
"交流群": "กลุ่มสื่อสาร",
"例句中加粗单词": "คำหยาบในประโยคตัวอย่าง"
}

View File

@ -798,5 +798,7 @@
"对齐": "yönlendirme",
"居左": "sol tarafta",
"居右": "Sağda ol.",
"截图保存格式": "Ekran Görüntüsü Kaydet Format"
"截图保存格式": "Ekran Görüntüsü Kaydet Format",
"交流群": "İletişim grupları",
"例句中加粗单词": "Örneğin cümlelerinde kalın kelimeler"
}

View File

@ -798,5 +798,7 @@
"对齐": "вирівнювання",
"居左": "бути ліворуч,",
"居右": "бути праворуч",
"截图保存格式": "Формат збереження знімка екрана"
"截图保存格式": "Формат збереження знімка екрана",
"交流群": "Групи комунікації",
"例句中加粗单词": "Жирі слова у прикладному реченні"
}

View File

@ -798,5 +798,7 @@
"对齐": "Canh lề",
"居左": "Trái",
"居右": "Bên phải",
"截图保存格式": "Định dạng lưu ảnh chụp màn hình"
"截图保存格式": "Định dạng lưu ảnh chụp màn hình",
"交流群": "Nhóm trao đổi",
"例句中加粗单词": "Từ in đậm trong câu ví dụ"
}

View File

@ -799,5 +799,6 @@
"居左": "",
"居右": "",
"截图保存格式": "",
"交流群": ""
"交流群": "",
"例句中加粗单词": ""
}