i18n with gettext
This commit is contained in:
@@ -8,6 +8,7 @@ from highlight_regex import HighlightRegex
|
||||
from highlighting import Highlighting
|
||||
from settings import Settings
|
||||
|
||||
from raven.i18n import _
|
||||
|
||||
class PayloadItem(QListWidgetItem):
|
||||
def __init__(self, text: str, payload=None):
|
||||
@@ -18,7 +19,7 @@ class PayloadItem(QListWidgetItem):
|
||||
class HighlightingDialog(QDialog):
|
||||
def __init__(self, settings: Settings):
|
||||
super(HighlightingDialog, self).__init__()
|
||||
self.setWindowTitle(self.tr("Manage Highlighting"))
|
||||
self.setWindowTitle(_("Manage Highlighting"))
|
||||
self.setModal(True)
|
||||
self._settings = settings
|
||||
|
||||
@@ -30,23 +31,23 @@ class HighlightingDialog(QDialog):
|
||||
form_grid.addWidget(self.list, row, 0, 1, 2)
|
||||
|
||||
row = row + 1
|
||||
self.btn_add = QPushButton(QIcon.fromTheme("list-add"), self.tr("Add"))
|
||||
self.btn_add = QPushButton(QIcon.fromTheme("list-add"), _("Add"))
|
||||
self.btn_add.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_add.pressed.connect(self._add)
|
||||
|
||||
self.btn_update = QPushButton(QIcon.fromTheme("stock_edit"), self.tr("Update"))
|
||||
self.btn_update = QPushButton(QIcon.fromTheme("stock_edit"), _("Update"))
|
||||
self.btn_update.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_update.pressed.connect(self._update)
|
||||
|
||||
self.btn_delete = QPushButton(QIcon.fromTheme("list-remove"), self.tr("Remove"))
|
||||
self.btn_delete = QPushButton(QIcon.fromTheme("list-remove"), _("Remove"))
|
||||
self.btn_delete.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_delete.pressed.connect(self._delete)
|
||||
|
||||
self.btn_move_up = QPushButton(QIcon.fromTheme("go-up"), self.tr("Up"))
|
||||
self.btn_move_up = QPushButton(QIcon.fromTheme("go-up"), _("Up"))
|
||||
self.btn_move_up.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_move_up.pressed.connect(self._move_up)
|
||||
|
||||
self.btn_move_down = QPushButton(QIcon.fromTheme("go-down"), self.tr("Down"))
|
||||
self.btn_move_down = QPushButton(QIcon.fromTheme("go-down"), _("Down"))
|
||||
self.btn_move_down.setSizePolicy(QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed))
|
||||
self.btn_move_down.pressed.connect(self._move_down)
|
||||
button_box = HBox(self.btn_update, self.btn_add, self.btn_delete, self.btn_move_up, self.btn_move_down)
|
||||
@@ -54,26 +55,26 @@ class HighlightingDialog(QDialog):
|
||||
|
||||
row = row + 1
|
||||
self.query = QLineEdit(self)
|
||||
form_grid.addWidget(QLabel(self.tr("Query:")), row, 0)
|
||||
form_grid.addWidget(QLabel(_("Query:")), row, 0)
|
||||
form_grid.addWidget(self.query, row, 1)
|
||||
|
||||
row = row + 1
|
||||
self.ignore_case = QCheckBox(self.tr("Ignore Case"))
|
||||
self.ignore_case = QCheckBox(_("Ignore Case"))
|
||||
self.ignore_case.setChecked(True)
|
||||
form_grid.addWidget(self.ignore_case, row, 0, 1, 2)
|
||||
|
||||
row = row + 1
|
||||
self.is_regex = QCheckBox(self.tr("Regular Expression"))
|
||||
self.is_regex = QCheckBox(_("Regular Expression"))
|
||||
self.is_regex.setChecked(True)
|
||||
form_grid.addWidget(self.is_regex, row, 0, 1, 2)
|
||||
|
||||
row = row + 1
|
||||
form_grid.addWidget(QLabel(self.tr("Hit Background:")), row, 0)
|
||||
form_grid.addWidget(QLabel(_("Hit Background:")), row, 0)
|
||||
self.hit_background_color = ColorButton("ccb400")
|
||||
form_grid.addWidget(self.hit_background_color, row, 1)
|
||||
|
||||
row = row + 1
|
||||
form_grid.addWidget(QLabel(self.tr("Line Background:")), row, 0)
|
||||
form_grid.addWidget(QLabel(_("Line Background:")), row, 0)
|
||||
self.line_background_color = ColorButton("fff080")
|
||||
form_grid.addWidget(self.line_background_color, row, 1)
|
||||
|
||||
@@ -137,10 +138,10 @@ class HighlightingDialog(QDialog):
|
||||
def _save(self):
|
||||
|
||||
if self._is_dirty():
|
||||
unsaved = QMessageBox(QMessageBox.Icon.Question, self.tr("unsaved changes"),
|
||||
self.tr("You have unsaved changes. Continue?"))
|
||||
unsaved = QMessageBox(QMessageBox.Icon.Question, _("unsaved changes"),
|
||||
_("You have unsaved changes. Continue?"))
|
||||
unsaved.setStandardButtons(QMessageBox.StandardButton.Cancel)
|
||||
unsaved.addButton(QPushButton(self.tr("Continue")), QMessageBox.ButtonRole.AcceptRole)
|
||||
unsaved.addButton(QPushButton(_("Continue")), QMessageBox.ButtonRole.AcceptRole)
|
||||
result = unsaved.exec()
|
||||
if result == QMessageBox.StandardButton.Cancel:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user