i18n with QT

This commit is contained in:
2022-02-01 18:29:54 +01:00
parent 26e2ee89e8
commit 939c86dbe2
11 changed files with 356 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
import sys
from typing import Optional
from typing import Optional, Callable
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QDockWidget
@@ -16,8 +16,12 @@ from raven.plugins.ravenlog.Tab import Tab
class RavenLogPlugin(PluginBase):
def __init__(self):
super(RavenLogPlugin, self).__init__()
self.tr = None
self.main_window = None
def set_translator(self, tr: Callable[[str], str]):
self.tr = tr
def create_main_window(self):
if not self.main_window:
self.main_window = MainWindow()
@@ -42,7 +46,7 @@ class RavenLogPlugin(PluginBase):
def _action_about(self) -> RAction:
about_action = RAction(
"&About",
self.tr("&About"),
action=lambda: AboutDialog().exec(),
icon_file=constants.raven_icon
)
@@ -50,6 +54,6 @@ class RavenLogPlugin(PluginBase):
def _action_close(self) -> RAction:
icon = "close" if sys.platform == 'win32' or sys.platform == 'cygwin' else "exit"
close_action = RAction("E&xit", action=lambda: self.main_window.destruct(), shortcut='Ctrl+X',
close_action = RAction(self.tr("E&xit"), action=lambda: self.main_window.destruct(), shortcut='Ctrl+X',
icon_from_theme=icon)
return close_action