Skip to content

Commit

Permalink
feat: Added content types for filter in Advanced mode. resolved #281
Browse files Browse the repository at this point in the history
  • Loading branch information
bookfere committed Apr 17, 2024
1 parent 450b6f7 commit c631005
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 42 deletions.
17 changes: 15 additions & 2 deletions advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ def layout_filter(self):
categories.addItem(_('Translated'), 'translated')
categories.addItem(_('Untranslated'), 'untranslated')

content_types = QComboBox()
content_types.addItem(_('Original Text'), 'original_text')
content_types.addItem(_('Original Code'), 'original_code')
content_types.addItem(_('Translation Text'), 'translation_text')

search_input = QLineEdit()
search_input.setPlaceholderText(_('keyword for filtering'))

Expand All @@ -515,12 +520,19 @@ def filter_table_items(index):

def filter_by_category(index):
filter_table_items(index)
self.table.show_by_text(search_input.text())
self.table.show_by_text(
search_input.text(), content_types.currentData())
categories.currentIndexChanged.connect(filter_by_category)

def filter_by_content_type(index):
filter_table_items(categories.currentIndex())
self.table.show_by_text(
search_input.text(), content_types.itemData(index))
content_types.currentIndexChanged.connect(filter_by_content_type)

def filter_by_keyword(text):
filter_table_items(categories.currentIndex())
self.table.show_by_text(text)
self.table.show_by_text(text, content_types.currentData())
search_input.textChanged.connect(filter_by_keyword)

# def reset_filter():
Expand All @@ -530,6 +542,7 @@ def filter_by_keyword(text):
# self.trans_worker.finished.connect(reset_filter)

layout.addWidget(categories)
layout.addWidget(content_types)
layout.addWidget(search_input)

return widget
Expand Down
11 changes: 9 additions & 2 deletions components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,22 @@ def show_all_rows(self):
for row in range(self.rowCount()):
self.showRow(row)

def show_by_text(self, text):
def show_by_text(self, text, content_type):
if not text:
return
paragraphs = []
for row in range(self.rowCount()):
if self.isRowHidden(row):
continue
paragraph = self.paragraph(row)
if text.lower() not in paragraph.original.lower():
if content_type == 'original_code':
content = paragraph.raw.lower()
elif content_type == 'translation_text':
content = '' if paragraph.translation is None else \
paragraph.translation.lower()
else:
content = paragraph.original.lower()
if text.lower() not in content:
paragraphs.append(paragraph)
self.hide_by_paragraphs(paragraphs)

Expand Down
11 changes: 10 additions & 1 deletion translations/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-15 12:45+0800\n"
"POT-Creation-Date: 2024-04-17 21:48+0800\n"
"PO-Revision-Date: 2023-04-17 14:17+0800\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -85,6 +85,15 @@ msgstr ""
msgid "Untranslated"
msgstr ""

msgid "Original Text"
msgstr ""

msgid "Original Code"
msgstr ""

msgid "Translation Text"
msgstr ""

msgid "keyword for filtering"
msgstr ""

Expand Down
11 changes: 10 additions & 1 deletion translations/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-15 12:45+0800\n"
"POT-Creation-Date: 2024-04-17 21:48+0800\n"
"PO-Revision-Date: 2023-10-01 15:35-0400\n"
"Last-Translator: <a href=\"https://www.mobileread.com/forums/member.php?"
"u=90932\">PoP</a>\n"
Expand Down Expand Up @@ -85,6 +85,15 @@ msgstr "Traduit"
msgid "Untranslated"
msgstr "Non-traduit"

msgid "Original Text"
msgstr ""

msgid "Original Code"
msgstr ""

msgid "Translation Text"
msgstr ""

msgid "keyword for filtering"
msgstr ""

Expand Down
76 changes: 44 additions & 32 deletions translations/message.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-15 12:45+0800\n"
"POT-Creation-Date: 2024-04-17 21:48+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -51,7 +51,7 @@ msgstr ""
msgid "Input Format"
msgstr ""

#: advanced.py:261 advanced.py:714 batch.py:72 setting.py:380
#: advanced.py:261 advanced.py:727 batch.py:72 setting.py:380
msgid "Target Language"
msgstr ""

Expand Down Expand Up @@ -95,7 +95,7 @@ msgstr ""
msgid "Non-aligned"
msgstr ""

#: advanced.py:498 advanced.py:804 components/indicator.py:13
#: advanced.py:498 advanced.py:817 components/indicator.py:13
#: components/table.py:99
msgid "Translated"
msgstr ""
Expand All @@ -105,122 +105,134 @@ msgid "Untranslated"
msgstr ""

#: advanced.py:502
msgid "Original Text"
msgstr ""

#: advanced.py:503
msgid "Original Code"
msgstr ""

#: advanced.py:504
msgid "Translation Text"
msgstr ""

#: advanced.py:507
msgid "keyword for filtering"
msgstr ""

#: advanced.py:582
#: advanced.py:595
msgid "Total items: {}"
msgstr ""

#: advanced.py:583 lib/translation.py:240
#: advanced.py:596 lib/translation.py:240
msgid "Character count: {}"
msgstr ""

#: advanced.py:592
#: advanced.py:605
msgid "Non-aligned items: {}"
msgstr ""

#: advanced.py:625 cache.py:96 cache.py:185 components/engine.py:201
#: advanced.py:638 cache.py:96 cache.py:185 components/engine.py:201
#: components/table.py:171
msgid "Delete"
msgstr ""

#: advanced.py:626
#: advanced.py:639
msgid "Translate All"
msgstr ""

#: advanced.py:627
#: advanced.py:640
msgid "Translate Selected"
msgstr ""

#: advanced.py:652 advanced.py:667
#: advanced.py:665 advanced.py:680
msgid "Stop"
msgstr ""

#: advanced.py:657
#: advanced.py:670
msgid "Are you sure you want to stop the translation progress?"
msgstr ""

#: advanced.py:661
#: advanced.py:674
msgid "Stopping..."
msgstr ""

#: advanced.py:692
#: advanced.py:705
msgid "Cache Status"
msgstr ""

#: advanced.py:695
#: advanced.py:708
msgid "Disabled"
msgstr ""

#: advanced.py:695
#: advanced.py:708
msgid "Enabled"
msgstr ""

#: advanced.py:702 setting.py:339
#: advanced.py:715 setting.py:339
msgid "Translation Engine"
msgstr ""

#: advanced.py:708 batch.py:72 setting.py:379
#: advanced.py:721 batch.py:72 setting.py:379
msgid "Source Language"
msgstr ""

#: advanced.py:720
#: advanced.py:733
msgid "Custom Ebook Title"
msgstr ""

#: advanced.py:725
#: advanced.py:738
msgid "By default, title metadata will be translated."
msgstr ""

#: advanced.py:754
#: advanced.py:767
msgid "Output Ebook"
msgstr ""

#: advanced.py:756
#: advanced.py:769
msgid "Output"
msgstr ""

#: advanced.py:805
#: advanced.py:818
msgid "The ebook has not been translated yet."
msgstr ""

#: advanced.py:809
#: advanced.py:822
msgid ""
"The number of lines in some translation units differs between the original "
"text and the translated text. Are you sure you want to output without "
"checking alignment?"
msgstr ""

#: advanced.py:844
#: advanced.py:857
msgid "No translation yet"
msgstr ""

#: advanced.py:896 components/engine.py:207 setting.py:98
#: advanced.py:909 components/engine.py:207 setting.py:98
msgid "Save"
msgstr ""

#: advanced.py:974
#: advanced.py:987
msgid "Your changes have been saved."
msgstr ""

#: advanced.py:986
#: advanced.py:999
msgid "Translation log"
msgstr ""

#: advanced.py:997
#: advanced.py:1010
msgid "Error log"
msgstr ""

#: advanced.py:1017
#: advanced.py:1030
msgid "Are you sure you want to translate all {:n} paragraphs?"
msgstr ""

#: advanced.py:1045
#: advanced.py:1058
msgid "Are you sure you want to cancel the preparation progress?"
msgstr ""

#: advanced.py:1056
#: advanced.py:1069
msgid "Are you sure you want to cancel the translation progress?"
msgstr ""

Expand Down Expand Up @@ -449,7 +461,7 @@ msgstr ""
msgid "Select similar paragraphs: {}=\"{}\""
msgstr ""

#: components/table.py:261
#: components/table.py:268
msgid "Retain at least one row."
msgstr ""

Expand Down
11 changes: 10 additions & 1 deletion translations/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-15 12:45+0800\n"
"POT-Creation-Date: 2024-04-17 21:48+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -84,6 +84,15 @@ msgstr "Traduzido"
msgid "Untranslated"
msgstr "Não traduzido"

msgid "Original Text"
msgstr ""

msgid "Original Code"
msgstr ""

msgid "Translation Text"
msgstr ""

msgid "keyword for filtering"
msgstr ""

Expand Down
11 changes: 10 additions & 1 deletion translations/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-15 12:45+0800\n"
"POT-Creation-Date: 2024-04-17 21:48+0800\n"
"PO-Revision-Date: 2024-03-23 15:12+0300\n"
"Last-Translator: DogancanYr <EMAIL@ADDRESS>\n"
"Language-Team: Turkish <[email protected]>\n"
Expand Down Expand Up @@ -84,6 +84,15 @@ msgstr "Çeviri"
msgid "Untranslated"
msgstr "çevrilmemiş"

msgid "Original Text"
msgstr ""

msgid "Original Code"
msgstr ""

msgid "Translation Text"
msgstr ""

msgid "keyword for filtering"
msgstr ""

Expand Down
Binary file modified translations/zh_CN.mo
Binary file not shown.
11 changes: 10 additions & 1 deletion translations/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Ebook Translator Calibre Plugin\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-04-15 12:45+0800\n"
"POT-Creation-Date: 2024-04-17 21:48+0800\n"
"PO-Revision-Date: 2023-04-17 14:17+0800\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -82,6 +82,15 @@ msgstr "已翻译"
msgid "Untranslated"
msgstr "未翻译"

msgid "Original Text"
msgstr "原文文本"

msgid "Original Code"
msgstr "原文代码"

msgid "Translation Text"
msgstr "译文文本"

msgid "keyword for filtering"
msgstr "筛选关键词"

Expand Down
Loading

0 comments on commit c631005

Please sign in to comment.