feat: translate more stuff

This commit is contained in:
Jann Stute
2024-12-23 20:28:14 +01:00
parent c76b6ed78f
commit e2c1440fb9
6 changed files with 34 additions and 37 deletions

View File

@@ -50,6 +50,9 @@
"file.not_found": "File Not Found",
"file.open_file_with": "Open file with",
"file.open_file": "Open file",
"file.open_file.windows": "Open file in Explorer",
"file.open_file.macos": "Open file in Finder",
"file.open_file.other": "Open file in file explorer",
"file.open_location.generic": "Show file in explorer",
"file.open_location.mac": "Reveal in Finder",
"file.open_location.windows": "Show in File Explorer",
@@ -81,6 +84,7 @@
"generic.navigation.next": "Next",
"generic.paste": "Paste",
"generic.recent_libraries": "Recent Libraries",
"generic.filename": "Filename",
"help.visit_github": "Visit GitHub Repository",
"home.search_entries": "Search Entries",
"home.search_library": "Search Library",
@@ -180,5 +184,6 @@
"drop_import.progress.label.plural": "Importing New Files...\n{count} Files Imported.{suffix}",
"drop_import.progress.window_title": "Import Files",
"drop_import.duplicates_choice.singular": "The following file has a filename that already exists in the library.",
"drop_import.duplicates_choice.plural": "The following {count} files have filenames that already exist in the library."
"drop_import.duplicates_choice.plural": "The following {count} files have filenames that already exist in the library.",
"landing.open_create_library": "Open/Create Library {shortcut}"
}

View File

@@ -25,6 +25,8 @@ from PySide6.QtWidgets import (QComboBox, QFrame, QGridLayout,
from src.qt.pagination import Pagination
from src.qt.widgets.landing import LandingWidget
from .translations import Translations
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from src.qt.ts_qt import QtDriver
@@ -77,6 +79,8 @@ class Ui_MainWindow(QMainWindow):
# Thumbnail Size placeholder
self.thumb_size_combobox = QComboBox(self.centralwidget)
self.thumb_size_combobox.setObjectName(u"thumbSizeComboBox")
Translations.translate_with_setter(self.thumb_size_combobox.setPlaceholderText, "home.thumbnail_size")
self.thumb_size_combobox.setCurrentText("")
sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
@@ -128,7 +132,7 @@ class Ui_MainWindow(QMainWindow):
self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.horizontalLayout_2.setSizeConstraint(QLayout.SetMinimumSize)
self.backButton = QPushButton(self.centralwidget)
self.backButton = QPushButton("<", self.centralwidget)
self.backButton.setObjectName(u"backButton")
self.backButton.setMinimumSize(QSize(0, 32))
self.backButton.setMaximumSize(QSize(32, 16777215))
@@ -139,7 +143,7 @@ class Ui_MainWindow(QMainWindow):
self.horizontalLayout_2.addWidget(self.backButton)
self.forwardButton = QPushButton(self.centralwidget)
self.forwardButton = QPushButton(">", self.centralwidget)
self.forwardButton.setObjectName(u"forwardButton")
self.forwardButton.setMinimumSize(QSize(0, 32))
self.forwardButton.setMaximumSize(QSize(32, 16777215))
@@ -152,6 +156,7 @@ class Ui_MainWindow(QMainWindow):
self.horizontalLayout_2.addWidget(self.forwardButton)
self.searchField = QLineEdit(self.centralwidget)
Translations.translate_with_setter(self.searchField.setPlaceholderText, "home.search_entries")
self.searchField.setObjectName(u"searchField")
self.searchField.setMinimumSize(QSize(0, 32))
font2 = QFont()
@@ -167,6 +172,7 @@ class Ui_MainWindow(QMainWindow):
self.horizontalLayout_2.addWidget(self.searchField)
self.searchButton = QPushButton(self.centralwidget)
Translations.translate_qobject(self.searchButton, "home.search")
self.searchButton.setObjectName(u"searchButton")
self.searchButton.setMinimumSize(QSize(0, 32))
self.searchButton.setFont(font2)
@@ -186,33 +192,9 @@ class Ui_MainWindow(QMainWindow):
self.statusbar.setSizePolicy(sizePolicy1)
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate(
"MainWindow", u"MainWindow", None))
# Navigation buttons
self.backButton.setText(
QCoreApplication.translate("MainWindow", u"<", None)) #TODO translate
self.forwardButton.setText(
QCoreApplication.translate("MainWindow", u">", None)) #TODO translate
# Search field
self.searchField.setPlaceholderText(
QCoreApplication.translate("MainWindow", u"Search Entries", None)) #TODO translate
self.searchButton.setText(
QCoreApplication.translate("MainWindow", u"Search", None)) #TODO translate
self.thumb_size_combobox.setCurrentText("")
# Thumbnail size selector
self.thumb_size_combobox.setPlaceholderText(
QCoreApplication.translate("MainWindow", u"Thumbnail Size", None)) #TODO translate
# retranslateUi
def moveEvent(self, event) -> None:
# time.sleep(0.02) # sleep for 20ms
pass

View File

@@ -6,11 +6,13 @@
import platform
from .translations import Translations
class PlatformStrings:
open_file_str: str = "Open in file explorer"
open_file_str: str = Translations["file.open_file.other"]
if platform.system() == "Windows":
open_file_str = "Open in Explorer" # TODO translate
open_file_str = Translations["file.open_file.windows"]
elif platform.system() == "Darwin":
open_file_str = "Reveal in Finder" # TODO translate
open_file_str = Translations["file.open_file.macos"]

View File

@@ -147,14 +147,14 @@ class Ui_MainWindow(object):
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
self.comboBox_2.setItemText(0, QCoreApplication.translate("MainWindow", u"And (includes all tags)", None)) # TODO remove?
self.comboBox_2.setItemText(1, QCoreApplication.translate("MainWindow", u"Or (includes any tag)", None)) # TODO remove?
self.comboBox_2.setItemText(0, QCoreApplication.translate("MainWindow", u"And (includes all tags)", None))
self.comboBox_2.setItemText(1, QCoreApplication.translate("MainWindow", u"Or (includes any tag)", None))
self.comboBox.setCurrentText("")
self.comboBox.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Thumbnail Size", None)) # TODO translate?
self.comboBox.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Thumbnail Size", None))
self.backButton.setText(QCoreApplication.translate("MainWindow", u"<", None))
self.forwardButton.setText(QCoreApplication.translate("MainWindow", u">", None))
self.searchField.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Search Entries", None)) # TODO translate?
self.searchField.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Search Entries", None))
self.searchButton.setText(QCoreApplication.translate("MainWindow", u"Search", None))
# retranslateUi

View File

@@ -33,6 +33,8 @@ from src.qt.platform_strings import PlatformStrings
from src.qt.widgets.thumb_button import ThumbButton
from src.qt.widgets.thumb_renderer import ThumbRenderer
from ..translations import Translations
if TYPE_CHECKING:
from src.qt.ts_qt import QtDriver
@@ -217,7 +219,8 @@ class ItemThumb(FlowWidget):
self.thumb_button.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu)
self.opener = FileOpenerHelper("")
open_file_action = QAction("Open file", self) # TODO translate
open_file_action = QAction(self)
Translations.translate_qobject(open_file_action, "file.open_file")
open_file_action.triggered.connect(self.opener.open_file)
open_explorer_action = QAction(PlatformStrings.open_file_str, self)
open_explorer_action.triggered.connect(self.opener.open_explorer)
@@ -306,7 +309,8 @@ class ItemThumb(FlowWidget):
self.cb_layout.addWidget(badge)
# Filename Label =======================================================
self.file_label = QLabel(text="Filename") # TODO translate
self.file_label = QLabel()
Translations.translate_qobject(self.file_label, "generic.filename")
self.file_label.setStyleSheet(ItemThumb.filename_style)
self.file_label.setMaximumHeight(self.label_height)
if not show_filename_label:

View File

@@ -15,6 +15,8 @@ from PySide6.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget
from src.qt.helpers.color_overlay import gradient_overlay, theme_fg_overlay
from src.qt.widgets.clickable_label import ClickableLabel
from ..translations import Translations
# Only import for type checking/autocompletion, will not be imported at runtime.
if typing.TYPE_CHECKING:
from src.qt.ts_qt import QtDriver
@@ -62,7 +64,9 @@ class LandingWidget(QWidget):
open_shortcut_text = "(Ctrl+O)"
self.open_button: QPushButton = QPushButton()
self.open_button.setMinimumWidth(200)
self.open_button.setText(f"Open/Create Library {open_shortcut_text}") # TODO translate
Translations.translate_qobject(
self.open_button, "landing.open_create_library", shortcut=open_shortcut_text
)
self.open_button.clicked.connect(self.driver.open_library_from_dialog)
# Create status label --------------------------------------------------