Skip to content

Commit

Permalink
feat: Discard translations that are identical to the original in meta…
Browse files Browse the repository at this point in the history
…data.
  • Loading branch information
bookfere committed Mar 29, 2024
1 parent 521af38 commit 0ee0f33
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ __Plugin Homepage__: [https://translator.bookfere.com](https://translator.bookfe
* [Installation](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki/English#installation)
* [Usage](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki/English#usage)
* [Settings](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki/English#settings)
* [Contributing](CONTRIBUTING.md)

---

Expand All @@ -41,8 +40,8 @@ __Plugin Homepage__: [https://translator.bookfere.com](https://translator.bookfe
* [GitHub ](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin)
* [MobileRead](https://www.mobileread.com/forums/showthread.php?t=353052)
* [Release](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/releases)
* [Contributing](CONTRIBUTING.md)
* [Donate](https://www.paypal.com/paypalme/bookfere)
* [Sponsor](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki#sponsor)

---

Expand Down
3 changes: 1 addition & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ __插件主页__:[https://translator.bookfere.com](https://translator.bookfere
* [安装插件](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki/简体中文#安装插件)
* [使用方法](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki/简体中文#使用方法)
* [设置说明](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki/简体中文#设置说明)
* [贡献代码](CONTRIBUTING.md)

---

Expand All @@ -41,8 +40,8 @@ __插件主页__:[https://translator.bookfere.com](https://translator.bookfere
* [MobileRead](https://www.mobileread.com/forums/showthread.php?t=353052)
* [发布页面](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/releases)
* [详细介绍](https://bookfere.com/post/1057.html)
* [贡献代码](CONTRIBUTING.md)
* [捐助页面](https://bookfere.com/donate)
* [致谢列表](https://github.com/bookfere/Ebook-Translator-Calibre-Plugin/wiki#sponsor)

---

Expand Down
2 changes: 1 addition & 1 deletion lib/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_content(self):
return self.element.content

def add_translation(self, translation=None):
if translation is not None:
if translation is not None and translation != self.get_content():
if self.position == 'only':
self.element.content = translation
elif self.position in ['above', 'left']:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ def test_add_translation_only(self):
self.element.add_translation('A')
self.assertEqual('A', self.element.element.content)

def test_add_translation_same_content(self):
self.element.add_translation('a')
self.assertEqual('a', self.element.element.content)


class TestTocElement(unittest.TestCase):
def setUp(self):
Expand Down

0 comments on commit 0ee0f33

Please sign in to comment.