i18n with gettext

This commit is contained in:
2022-02-02 19:35:57 +01:00
parent 939c86dbe2
commit 9c28a41904
21 changed files with 686 additions and 437 deletions

View File

@@ -8,24 +8,24 @@ from PySide6.QtWidgets import *
import constants
from label import Label
from vbox import VBox
from raven.i18n import _
class AboutDialog(QDialog):
"""Dialog for showing info about RavenLog"""
def __init__(self, parent=None):
super(AboutDialog, self).__init__(parent)
self.setWindowTitle(self.tr("About RavenLog"))
self.setWindowTitle(_("About RavenLog"))
self.setModal(True)
self.layout = QVBoxLayout(self)
heading_app_name = QLabel(self.tr("RavenLog"))
heading_app_name = QLabel(_("RavenLog"))
heading_app_name.setAlignment(Qt.AlignmentFlag.AlignLeft)
heading_app_name.setFont(QFont("default", 25))
heading_app_name.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
version = QLabel(self.tr("Version: {0}".format(self._version())))
version = QLabel(_("Version: {0}".format(self._version())))
version.setAlignment(Qt.AlignmentFlag.AlignLeft)
app_icon = QLabel()
@@ -40,8 +40,8 @@ class AboutDialog(QDialog):
self.layout.addWidget(heading)
tabs = QTabWidget()
tabs.addTab(self._about(), self.tr("About"))
tabs.addTab(self._license(), self.tr("License"))
tabs.addTab(self._about(), _("About"))
tabs.addTab(self._license(), _("License"))
self.layout.addWidget(tabs)
@@ -53,7 +53,7 @@ class AboutDialog(QDialog):
def _about(self) -> QWidget:
result = QWidget()
result.layout = QVBoxLayout(result)
label = Label(self.tr(textwrap.dedent("""
label = Label(_(textwrap.dedent("""
Log file viewer<br>
(c) 2022 Open Text Corporation<br>
<a href="https://www.opentext.com/">License: LGPL v3</a>""")))
@@ -68,7 +68,7 @@ class AboutDialog(QDialog):
<li>urllib3 (MIT) - <a href="https://urllib3.readthedocs.io/en/stable/">https://urllib3.readthedocs.io/en/stable/</a></li>
<li>watchdog 2.16 (Apache 2.0) - <a href="https://github.com/gorakhargosh/watchdog">https://github.com/gorakhargosh/watchdog</a></li>
</ul>""".format(pyside=PySide6.__version__, qt=PySide6.QtCore.__version__)
label = self.tr(textwrap.dedent(dependencies))
label = _(textwrap.dedent(dependencies))
result = QWidget()
result.layout = QVBoxLayout(result)