Skip to content

Commit

Permalink
Adding translations to tasks and ok/cancel buttons (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus committed Jun 19, 2024
1 parent 826f62c commit 9b45e4d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
21 changes: 16 additions & 5 deletions buzz/locale/lv_LV/LC_MESSAGES/buzz.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-18 21:50+0300\n"
"PO-Revision-Date: 2024-06-18 21:39+0300\n"
"POT-Creation-Date: 2024-06-19 21:34+0300\n"
"PO-Revision-Date: 2024-06-19 21:34+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: lv_LV\n"
Expand All @@ -26,15 +26,26 @@ msgstr "Importēt URL"
msgid "https://example.com/audio.mp3"
msgstr "https://example.com/audio.mp3"

#: buzz/widgets/import_url_dialog.py:32
#: buzz/widgets/import_url_dialog.py:28
#: buzz/widgets/preferences_dialog/preferences_dialog.py:69
#: buzz/widgets/transcriber/advanced_settings_dialog.py:97
msgid "Ok"
msgstr "Labi"

#: buzz/widgets/import_url_dialog.py:29
#: buzz/widgets/preferences_dialog/preferences_dialog.py:70
msgid "Cancel"
msgstr "Atcelt"

#: buzz/widgets/import_url_dialog.py:34
msgid "URL:"
msgstr "URL:"

#: buzz/widgets/import_url_dialog.py:44
#: buzz/widgets/import_url_dialog.py:46
msgid "Invalid URL"
msgstr "Adrese nav derīga"

#: buzz/widgets/import_url_dialog.py:44
#: buzz/widgets/import_url_dialog.py:46
msgid "The URL you entered is invalid."
msgstr "Jūsu ievadītā URL adrese nav derīga."

Expand Down
6 changes: 6 additions & 0 deletions buzz/transcriber/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class Task(enum.Enum):
TRANSCRIBE = "transcribe"


TASK_LABEL_TRANSLATIONS = {
Task.TRANSLATE: _("Translate"),
Task.TRANSCRIBE: _("Tanscribe"),
}


@dataclass
class Segment:
start: int # start time in ms
Expand Down
2 changes: 2 additions & 0 deletions buzz/widgets/import_url_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def __init__(self, parent: Optional[QWidget] = None):
self.button_box = QDialogButtonBox(
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
)
self.button_box.button(QDialogButtonBox.StandardButton.Ok).setText(_("Ok"))
self.button_box.button(QDialogButtonBox.StandardButton.Cancel).setText(_("Cancel"))
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)

Expand Down
2 changes: 2 additions & 0 deletions buzz/widgets/preferences_dialog/preferences_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def __init__(
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel,
self,
)
button_box.button(QDialogButtonBox.StandardButton.Ok).setText(_("Ok"))
button_box.button(QDialogButtonBox.StandardButton.Cancel).setText(_("Cancel"))
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)

Expand Down
1 change: 1 addition & 0 deletions buzz/widgets/transcriber/advanced_settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def __init__(
button_box = QDialogButtonBox(
QDialogButtonBox.StandardButton(QDialogButtonBox.StandardButton.Ok), self
)
button_box.button(QDialogButtonBox.StandardButton.Ok).setText(_("Ok"))
button_box.accepted.connect(self.accept)

layout.addWidget(button_box)
Expand Down
6 changes: 3 additions & 3 deletions buzz/widgets/transcriber/tasks_combo_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt6.QtCore import pyqtSignal
from PyQt6.QtWidgets import QComboBox, QWidget

from buzz.transcriber.transcriber import Task
from buzz.transcriber.transcriber import Task, TASK_LABEL_TRANSLATIONS


class TasksComboBox(QComboBox):
Expand All @@ -14,9 +14,9 @@ class TasksComboBox(QComboBox):
def __init__(self, default_task: Task, parent: Optional[QWidget], *args) -> None:
super().__init__(parent, *args)
self.tasks = [i for i in Task]
self.addItems(map(lambda task: task.value.title(), self.tasks))
self.addItems(map(lambda task: TASK_LABEL_TRANSLATIONS[task], self.tasks))
self.currentIndexChanged.connect(self.on_index_changed)
self.setCurrentText(default_task.value.title())
self.setCurrentText(TASK_LABEL_TRANSLATIONS[default_task])

def on_index_changed(self, index: int):
self.taskChanged.emit(self.tasks[index])
10 changes: 2 additions & 8 deletions buzz/widgets/transcription_tasks_table_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from buzz.db.entity.transcription import Transcription
from buzz.locale import _
from buzz.settings.settings import Settings
from buzz.transcriber.transcriber import FileTranscriptionTask, Task
from buzz.transcriber.transcriber import FileTranscriptionTask, Task, TASK_LABEL_TRANSLATIONS
from buzz.widgets.record_delegate import RecordDelegate
from buzz.widgets.transcription_record import TranscriptionRecord

Expand Down Expand Up @@ -78,12 +78,6 @@ def format_record_status_text(record: QSqlRecord) -> str:
case _:
return ""


task_label_translations = {
Task.TRANSLATE: _("Translate"),
Task.TRANSCRIBE: _("Tanscribe"),
}

column_definitions = [
ColDef(
id="file_name",
Expand Down Expand Up @@ -112,7 +106,7 @@ def format_record_status_text(record: QSqlRecord) -> str:
column=Column.SOURCE,
width=120,
delegate=RecordDelegate(
text_getter=lambda record: task_label_translations[Task(record.value("task"))]
text_getter=lambda record: TASK_LABEL_TRANSLATIONS[Task(record.value("task"))]
),
),
ColDef(
Expand Down

0 comments on commit 9b45e4d

Please sign in to comment.