Skip to content

Commit

Permalink
Making strings translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus committed May 18, 2024
1 parent c5ef985 commit 99ece45
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ translation_po_all:
TMP_POT_FILE_PATH := $(shell mktemp)
PO_FILE_PATH := buzz/locale/${locale}/LC_MESSAGES/buzz.po
translation_po:
xgettext --from-code=UTF-8 -o "${TMP_POT_FILE_PATH}" -l python $(shell find buzz/widgets -name '*.py')
xgettext --from-code=UTF-8 -o "${TMP_POT_FILE_PATH}" -l python $(shell find buzz -name '*.py')
sed -i.bak 's/CHARSET/UTF-8/' ${TMP_POT_FILE_PATH} && rm ${TMP_POT_FILE_PATH}.bak
msgmerge -U ${PO_FILE_PATH} ${TMP_POT_FILE_PATH}

Expand Down
130 changes: 111 additions & 19 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-05-18 09:04+0300\n"
"PO-Revision-Date: 2024-05-18 10:26+0300\n"
"POT-Creation-Date: 2024-05-18 17:24+0300\n"
"PO-Revision-Date: 2024-05-18 16:28+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: lv_LV\n"
Expand All @@ -18,6 +18,39 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.4.3\n"

#: buzz/settings/shortcut.py:17
msgid "Open Record Window"
msgstr "Atvērt ieraksta logu"

#: buzz/settings/shortcut.py:18
msgid "Import File"
msgstr "Importēt failu"

#: buzz/settings/shortcut.py:19 buzz/widgets/import_url_dialog.py:19
msgid "Import URL"
msgstr "Importēt URL"

#: buzz/settings/shortcut.py:20
msgid "Open Preferences Window"
msgstr "Atvērt iestatījumu logu"

#: buzz/settings/shortcut.py:22
msgid "View Transcript Text"
msgstr "Aplūkot atpazīto tekstu"

#: buzz/settings/shortcut.py:23
msgid "View Transcript Timestamps"
msgstr "Aplūkot atpazīšanas laikus"

#: buzz/settings/shortcut.py:25 buzz/widgets/main_window_toolbar.py:60
#: buzz/widgets/main_window.py:199
msgid "Clear History"
msgstr "Notīrīt vēsturi"

#: buzz/settings/shortcut.py:26 buzz/widgets/main_window_toolbar.py:52
msgid "Cancel Transcription"
msgstr "Atcelt atpazīšanu"

#: buzz/widgets/transcription_tasks_table_widget.py:64
msgid "Completed"
msgstr "Pabeigts"
Expand Down Expand Up @@ -67,14 +100,6 @@ msgstr "Jauna atpazīšanas"
msgid "Open Transcript"
msgstr "Atvērt transkriptu"

#: buzz/widgets/main_window_toolbar.py:52
msgid "Cancel Transcription"
msgstr "Atcelt atpazīšanu"

#: buzz/widgets/main_window_toolbar.py:60 buzz/widgets/main_window.py:199
msgid "Clear History"
msgstr "Notīrīt vēsturi"

#: buzz/widgets/about_dialog.py:80
msgid "Check for updates"
msgstr "Pārbaudīt atjauninājumus"
Expand All @@ -83,10 +108,6 @@ msgstr "Pārbaudīt atjauninājumus"
msgid "You're up to date!"
msgstr "Jums ir jaunākā versija!"

#: buzz/widgets/import_url_dialog.py:19
msgid "Import URL"
msgstr "Importēt URL"

#: buzz/widgets/import_url_dialog.py:22
msgid "https://example.com/audio.mp3"
msgstr "https://example.com/audio.mp3"
Expand All @@ -101,7 +122,7 @@ msgstr "Adrese nav derīga"

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

#: buzz/widgets/recording_transcriber_widget.py:60
msgid "Live Recording"
Expand Down Expand Up @@ -153,7 +174,7 @@ msgid ""
"cannot be undone."
msgstr ""
"Vai tiešām vēlaties dzēst izvēlētos transkriptus? Šī ir neatgriezeniska "
"darbība. "
"darbība."

#: buzz/widgets/main_window.py:221
msgid "Select audio file"
Expand Down Expand Up @@ -193,6 +214,10 @@ msgstr "Sākums"
msgid "End"
msgstr "Beigas"

#: buzz/widgets/transcription_viewer/transcription_viewer_widget.py:89
msgid "Export"
msgstr "Eksportēt"

#: buzz/widgets/record_button.py:21
msgid "Stop"
msgstr "Apturēt"
Expand All @@ -217,6 +242,14 @@ msgstr "Sākotnējais vaicājums:"
msgid "Word-level timings"
msgstr "Dalīt pa vārdiem"

#: buzz/widgets/transcriber/file_transcription_form_widget.py:66
msgid "Export:"
msgstr "Eksportēt:"

#: buzz/widgets/transcriber/advanced_settings_button.py:9
msgid "Advanced..."
msgstr "Papildu iestatījumi..."

#: buzz/widgets/transcriber/initial_prompt_text_edit.py:10
msgid "Enter prompt..."
msgstr "Ievadiet vaicājumu..."
Expand All @@ -234,20 +267,75 @@ msgid "Language:"
msgstr "Valoda:"

#: buzz/widgets/transcriber/languages_combo_box.py:25
#: buzz/transcriber/transcriber.py:149
msgid "Detect Language"
msgstr "Noteikt valodu"

#: buzz/widgets/transcriber/file_transcriber_widget.py:79
msgid "Run"
msgstr "Palaist"
msgstr "Apstrādāt"

#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:42
msgid "Enable folder watch"
msgstr "Ieslēgt mapes vērošanu"

#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:47
#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:50
msgid "Browse"
msgstr "Izvēlēties"

#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:94
msgid "Input folder"
msgstr "Vērojamā mape"

#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:95
msgid "Output folder"
msgstr "Rezultātu mape"

#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:105
msgid "Select Input Folder"
msgstr "Izvēlieties vērojamo mapi"

#: buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py:114
msgid "Select Output Folder"
msgstr "Izvēlieties rezultātu mapi"

#: buzz/widgets/preferences_dialog/general_preferences_widget.py:31
msgid "Test"
msgstr "Pārbaudīt"

#: buzz/widgets/preferences_dialog/general_preferences_widget.py:37
msgid "OpenAI API key"
msgstr "OpenAI API atslēga"

#: buzz/widgets/preferences_dialog/general_preferences_widget.py:49
msgid "Default export file name"
msgstr "Eksporta faila nosaukums"

#: buzz/widgets/preferences_dialog/general_preferences_widget.py:74
#: buzz/widgets/preferences_dialog/general_preferences_widget.py:80
msgid "OpenAI API Key Test"
msgstr "OpenAI API atslēgas pārbaude"

#: buzz/widgets/preferences_dialog/general_preferences_widget.py:75
msgid ""
"Your API key is valid. Buzz will use this key to perform Whisper API "
"transcriptions."
msgstr ""
"Jūsu API atslēga ir derīga. Buzz izmantos to runas atpazīšanai ar Whisper "
"API."

#: buzz/widgets/preferences_dialog/models_preferences_widget.py:61
msgid "Group"
msgstr "Veids"

#: buzz/widgets/preferences_dialog/models_preferences_widget.py:70
msgid "Download"
msgstr "Lejupielādēt"

#: buzz/widgets/preferences_dialog/models_preferences_widget.py:75
msgid "Show file location"
msgstr "Rādīt faila atrašanos"
msgstr "Pādīt faila atrašanās vietu"

#: buzz/widgets/preferences_dialog/models_preferences_widget.py:83
msgid "Delete"
Expand All @@ -269,13 +357,17 @@ msgstr "Dzēst modeli"
msgid "Are you sure you want to delete the selected model?"
msgstr "Vai tiešām dzēst izvēlēto modeli?"

#: buzz/widgets/preferences_dialog/shortcuts_editor_preferences_widget.py:29
msgid "Reset to Defaults"
msgstr "Atjaunot noklusētos"

#: buzz/widgets/preferences_dialog/preferences_dialog.py:50
msgid "General"
msgstr "Vizpārīgi"

#: buzz/widgets/preferences_dialog/preferences_dialog.py:53
msgid "Models"
msgstr "Modelis"
msgstr "Modeļi"

#: buzz/widgets/preferences_dialog/preferences_dialog.py:57
msgid "Shortcuts"
Expand Down
17 changes: 9 additions & 8 deletions buzz/settings/shortcut.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import enum
import typing
from buzz.locale import _


class Shortcut(str, enum.Enum):
Expand All @@ -13,16 +14,16 @@ def __new__(cls, sequence: str, description: str):
obj.description = description
return obj

OPEN_RECORD_WINDOW = ("Ctrl+R", "Open Record Window")
OPEN_IMPORT_WINDOW = ("Ctrl+O", "Import File")
OPEN_IMPORT_URL_WINDOW = ("Ctrl+U", "Import URL")
OPEN_PREFERENCES_WINDOW = ("Ctrl+,", "Open Preferences Window")
OPEN_RECORD_WINDOW = ("Ctrl+R", _("Open Record Window"))
OPEN_IMPORT_WINDOW = ("Ctrl+O", _("Import File"))
OPEN_IMPORT_URL_WINDOW = ("Ctrl+U", _("Import URL"))
OPEN_PREFERENCES_WINDOW = ("Ctrl+,", _("Open Preferences Window"))

VIEW_TRANSCRIPT_TEXT = ("Ctrl+E", "View Transcript Text")
VIEW_TRANSCRIPT_TIMESTAMPS = ("Ctrl+T", "View Transcript Timestamps")
VIEW_TRANSCRIPT_TEXT = ("Ctrl+E", _("View Transcript Text"))
VIEW_TRANSCRIPT_TIMESTAMPS = ("Ctrl+T", _("View Transcript Timestamps"))

CLEAR_HISTORY = ("Ctrl+S", "Clear History")
STOP_TRANSCRIPTION = ("Ctrl+X", "Cancel Transcription")
CLEAR_HISTORY = ("Ctrl+S", _("Clear History"))
STOP_TRANSCRIPTION = ("Ctrl+X", _("Cancel Transcription"))

@staticmethod
def get_default_shortcuts() -> typing.Dict[str, str]:
Expand Down
2 changes: 1 addition & 1 deletion buzz/widgets/model_download_progress_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def update_label_text(self, fraction_completed: float):
if fraction_completed > 0:
time_spent = (datetime.now() - self.start_time).total_seconds()
time_left = (time_spent / fraction_completed) - time_spent
label_text += f", {humanize.naturaldelta(time_left)} remaining"
label_text += f", {humanize.naturaldelta(time_left)} {_('remaining')}"
label_text += ")"

self.setLabelText(label_text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
QVBoxLayout,
)

from buzz.locale import _
from buzz.store.keyring_store import Key, get_password
from buzz.transcriber.transcriber import (
TranscriptionOptions,
Expand Down Expand Up @@ -38,15 +39,15 @@ def __init__(

self.config = config

checkbox = QCheckBox("Enable folder watch")
checkbox = QCheckBox(_("Enable folder watch"))
checkbox.setChecked(config.enabled)
checkbox.setObjectName("EnableFolderWatchCheckbox")
checkbox.stateChanged.connect(self.on_enable_changed)

input_folder_browse_button = QPushButton("Browse")
input_folder_browse_button = QPushButton(_("Browse"))
input_folder_browse_button.clicked.connect(self.on_click_browse_input_folder)

output_folder_browse_button = QPushButton("Browse")
output_folder_browse_button = QPushButton(_("Browse"))
output_folder_browse_button.clicked.connect(self.on_click_browse_output_folder)

input_folder_row = QHBoxLayout()
Expand Down Expand Up @@ -90,8 +91,8 @@ def __init__(
folders_form_layout = QFormLayout()

folders_form_layout.addRow("", checkbox)
folders_form_layout.addRow("Input folder", input_folder_row)
folders_form_layout.addRow("Output folder", output_folder_row)
folders_form_layout.addRow(_("Input folder"), input_folder_row)
folders_form_layout.addRow(_("Output folder"), output_folder_row)
folders_form_layout.addWidget(transcription_form_widget)

layout.addLayout(folders_form_layout)
Expand All @@ -101,7 +102,7 @@ def __init__(
self.setLayout(layout)

def on_click_browse_input_folder(self):
folder = QFileDialog.getExistingDirectory(self, "Select Input Folder")
folder = QFileDialog.getExistingDirectory(self, _("Select Input Folder"))

Check warning on line 105 in buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py#L105

Added line #L105 was not covered by tests
self.input_folder_line_edit.setText(folder)
self.on_input_folder_changed(folder)

Expand All @@ -110,7 +111,7 @@ def on_input_folder_changed(self, folder):
self.config_changed.emit(self.config)

def on_click_browse_output_folder(self):
folder = QFileDialog.getExistingDirectory(self, "Select Output Folder")
folder = QFileDialog.getExistingDirectory(self, _("Select Output Folder"))

Check warning on line 114 in buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/preferences_dialog/folder_watch_preferences_widget.py#L114

Added line #L114 was not covered by tests
self.output_folder_line_edit.setText(folder)
self.on_output_folder_changed(folder)

Expand Down
14 changes: 7 additions & 7 deletions buzz/widgets/preferences_dialog/general_preferences_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from buzz.store.keyring_store import get_password, Key
from buzz.widgets.line_edit import LineEdit
from buzz.widgets.openai_api_key_line_edit import OpenAIAPIKeyLineEdit

from buzz.locale import _

class GeneralPreferencesWidget(QWidget):
openai_api_key_changed = pyqtSignal(str)
Expand All @@ -28,13 +28,13 @@ def __init__(
self.on_openai_api_key_changed
)

self.test_openai_api_key_button = QPushButton("Test")
self.test_openai_api_key_button = QPushButton(_("Test"))
self.test_openai_api_key_button.clicked.connect(
self.on_click_test_openai_api_key_button
)
self.update_test_openai_api_key_button()

layout.addRow("OpenAI API key", self.openai_api_key_line_edit)
layout.addRow(_("OpenAI API key"), self.openai_api_key_line_edit)
layout.addRow("", self.test_openai_api_key_button)

self.settings = Settings()
Expand All @@ -46,7 +46,7 @@ def __init__(
self.on_default_export_file_name_changed
)
default_export_file_name_line_edit.setMinimumWidth(200)
layout.addRow("Default export file name", default_export_file_name_line_edit)
layout.addRow(_("Default export file name"), default_export_file_name_line_edit)

self.setLayout(layout)

Expand All @@ -71,13 +71,13 @@ def on_test_openai_api_key_success(self):
self.test_openai_api_key_button.setEnabled(True)
QMessageBox.information(
self,
"OpenAI API Key Test",
"Your API key is valid. Buzz will use this key to perform Whisper API transcriptions.",
_("OpenAI API Key Test"),
_("Your API key is valid. Buzz will use this key to perform Whisper API transcriptions."),
)

def on_test_openai_api_key_failure(self, error: str):
self.test_openai_api_key_button.setEnabled(True)
QMessageBox.warning(self, "OpenAI API Key Test", error)
QMessageBox.warning(self, _("OpenAI API Key Test"), error)

def on_openai_api_key_changed(self, key: str):
self.openai_api_key = key
Expand Down
4 changes: 2 additions & 2 deletions buzz/widgets/preferences_dialog/models_preferences_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
parent=self,
)
model_type_combo_box.changed.connect(self.on_model_type_changed)
layout.addRow("Group", model_type_combo_box)
layout.addRow(_("Group"), model_type_combo_box)

self.model_list_widget = QTreeWidget()
self.model_list_widget.setColumnCount(1)
Expand Down Expand Up @@ -188,7 +188,7 @@ def on_download_error(self, error: str):
self.progress_dialog = None
self.download_button.setEnabled(True)
self.reset()
QMessageBox.warning(self, _("Error"), f"Download failed: {error}")
QMessageBox.warning(self, _("Error"), f"{_('Download failed')}: {error}")

Check warning on line 191 in buzz/widgets/preferences_dialog/models_preferences_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/preferences_dialog/models_preferences_widget.py#L191

Added line #L191 was not covered by tests

def on_download_progress(self, progress: tuple):
self.progress_dialog.set_value(float(progress[0]) / progress[1])
Expand Down
Loading

0 comments on commit 99ece45

Please sign in to comment.