I18N Code Work done.
This commit is contained in:
@@ -17,7 +17,7 @@ from PyQt6.QtSql import QSqlQuery, QSqlQueryModel
|
||||
from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QStyledItemDelegate
|
||||
|
||||
from main import query_error
|
||||
from ui.PeopleDialog import Ui_Dialog
|
||||
from ui.PeopleDialog import Ui_PersonDialog
|
||||
|
||||
|
||||
class blockHandler(HTMLParser):
|
||||
@@ -104,7 +104,7 @@ class MLStripper(HTMLParser):
|
||||
return self.text.getvalue()
|
||||
|
||||
|
||||
class PersonDialog(QDialog, Ui_Dialog):
|
||||
class PersonDialog(QDialog, Ui_PersonDialog):
|
||||
SectionIdRole = Qt.ItemDataRole.UserRole
|
||||
SectionSequenceRole = Qt.ItemDataRole.UserRole + 1
|
||||
BookIdRole = Qt.ItemDataRole.UserRole + 2
|
||||
@@ -125,12 +125,12 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
if not query.exec():
|
||||
query_error(query)
|
||||
model.setQuery(query)
|
||||
self.bookCombo.setPlaceholderText("Select A Book")
|
||||
self.bookCombo.setPlaceholderText(self.tr("Select A Book"))
|
||||
self.bookCombo.setModel(model)
|
||||
self.bookCombo.setModelColumn(1)
|
||||
self.bookCombo.setCurrentIndex(-1)
|
||||
model: QStandardItemModel = QStandardItemModel() # type: ignore[no-redef]
|
||||
self.sectionCombo.setPlaceholderText("Select A Section")
|
||||
self.sectionCombo.setPlaceholderText(self.tr("Select A Section"))
|
||||
self.sectionCombo.setModel(model)
|
||||
self.sectionCombo.setEnabled(False)
|
||||
self.sectionCombo.setCurrentIndex(-1)
|
||||
@@ -168,7 +168,7 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
if not query.exec():
|
||||
query_error(query)
|
||||
if not query.next():
|
||||
raise Exception(f"No person record for {person_id}")
|
||||
raise Exception(self.tr("No person record for ") + f"{person_id}")
|
||||
self.person_id = person_id
|
||||
self.nameEdit.setText(query.value("name"))
|
||||
self.orgEdit.setText(query.value("organization"))
|
||||
@@ -183,7 +183,8 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
)
|
||||
if len(matches) != 1:
|
||||
raise Exception(
|
||||
f"Match failed looking for book_id: {query.value('book_id')}"
|
||||
self.tr("Match failed looking for book_id: ")
|
||||
+ f"{query.value('book_id')}"
|
||||
)
|
||||
row = int(matches[0].row())
|
||||
self.bookCombo.setCurrentIndex(row)
|
||||
@@ -215,10 +216,14 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
)
|
||||
html += "</head><body>\n"
|
||||
html += f"<h1>{title}</h1>\n"
|
||||
html += self.makeNotes()
|
||||
html += self.makeDefinitions()
|
||||
html += self.makeText()
|
||||
html += "</body>\n</html>\n"
|
||||
|
||||
#
|
||||
# XXX - Use the sound module, don't do this by hand
|
||||
#
|
||||
if self.sender() == self.printBtn:
|
||||
dev = None
|
||||
for output in QMediaDevices.audioOutputs():
|
||||
@@ -312,9 +317,8 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
book_id = model.data(model.createIndex(row, 0))
|
||||
query.bindValue(":book_id", book_id)
|
||||
section_id = self.sectionCombo.currentData(PersonDialog.SectionIdRole)
|
||||
print(f"section_id: {section_id}")
|
||||
if not section_id:
|
||||
raise Exception(f"Section id is null")
|
||||
raise Exception(self.tr("Section id is null"))
|
||||
if not query.exec():
|
||||
query_error(query)
|
||||
if self.person_id <= 0:
|
||||
@@ -426,7 +430,9 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
if not section_query.exec():
|
||||
query_error(section_query)
|
||||
if not section_query.next():
|
||||
raise Exception(f"Missing section {section_id}")
|
||||
raise Exception(
|
||||
self.tr("Missing section ") + f"{section_id}"
|
||||
)
|
||||
section = blockHandler()
|
||||
section.feed(section_query.value("content"))
|
||||
html += section.get_block(query.value("block")) + "\n"
|
||||
@@ -437,3 +443,24 @@ class PersonDialog(QDialog, Ui_Dialog):
|
||||
html = '<div class="stats">'
|
||||
html += "</div>\n"
|
||||
return html
|
||||
|
||||
def makeNotes(self) -> str:
|
||||
html = '<div class="notes">'
|
||||
query = QSqlQuery()
|
||||
query.prepare(
|
||||
"SELECT * FROM sessions " "WHERE session_id = :session_id"
|
||||
)
|
||||
row = self.sessionCombo.currentIndex()
|
||||
model = self.sessionCombo.model()
|
||||
index = model.index(row, 0)
|
||||
session_id = index.data()
|
||||
query.bindValue(":session_id", session_id)
|
||||
if not query.exec():
|
||||
query_error(query)
|
||||
first = True
|
||||
if not query.next():
|
||||
return ""
|
||||
html += "<h3>" + self.tr("Notes") + "</h3>\n"
|
||||
html += query.value("notes")
|
||||
html += "</div>"
|
||||
return html
|
||||
|
||||
Reference in New Issue
Block a user