Make link in DRM error dialog localized

This commit is contained in:
Kovid Goyal 2021-05-21 07:07:19 +05:30
parent aa3f34898d
commit 4f6763624b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 5 deletions

View File

@ -8,8 +8,9 @@ __docformat__ = 'restructuredtext en'
from qt.core import QDialog
from calibre.gui2.dialogs.drm_error_ui import Ui_Dialog
from polyglot.builtins import unicode_type
from calibre.utils.localization import localize_website_link
class DRMErrorMessage(QDialog, Ui_Dialog):
@ -17,7 +18,19 @@ class DRMErrorMessage(QDialog, Ui_Dialog):
def __init__(self, parent=None, title=None):
QDialog.__init__(self, parent)
self.setupUi(self)
msg = _('<p>This book is locked by <b>DRM</b>. To learn more about DRM'
' and why you cannot read or convert this book in calibre,'
' <a href="{0}">click here</a>.'
' </p>').format(localize_website_link('https://manual.calibre-ebook.com/drm.html'))
if title is not None:
t = unicode_type(self.msg.text())
self.msg.setText('<h2>%s</h2>%s'%(title, t))
msg = '<h2>%s</h2>%s'%(title, msg)
self.msg.setText(msg)
self.resize(self.sizeHint())
if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
d = DRMErrorMessage(title='testing title')
d.exec_()
del d

View File

@ -43,8 +43,7 @@
<item row="0" column="1">
<widget class="QLabel" name="msg">
<property name="text">
<string>&lt;p&gt;This book is locked by &lt;b&gt;DRM&lt;/b&gt;. To learn more about DRM and why you cannot read or convert this book in calibre,
&lt;a href=&quot;https://manual.calibre-ebook.com/drm.html&quot;&gt;click here&lt;/a&gt;.&lt;p&gt;</string>
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>