diff --git a/docs/changes/5.5.1.md b/docs/changes/5.5.1.md
index 141789ba23..86611870f3 100644
--- a/docs/changes/5.5.1.md
+++ b/docs/changes/5.5.1.md
@@ -12,7 +12,7 @@ Release date: `2024-xx-xx`
### Direct Transfer
-- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
+- [NXDRIVE-2915](https://jira.nuxeo.com/browse/NXDRIVE-2915): Translate "Document type" and "container type" labels on Direct Transfer popup
### Task Management
- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):
diff --git a/nxdrive/data/i18n/i18n.json b/nxdrive/data/i18n/i18n.json
index 00964d7e4f..e5a90c2921 100644
--- a/nxdrive/data/i18n/i18n.json
+++ b/nxdrive/data/i18n/i18n.json
@@ -11,11 +11,13 @@
"ADVANCED_SETTINGS": "Advanced settings",
"AGO": "ago",
"APPLY": "Apply",
+ "AUDIO": "Audio",
"AUTOLOCK": "Autolock",
"AUTH_EXPIRED": "Authentication expired",
"AUTH_UPDATE_ACTION": "Click here to log back in",
"AUTOMATIC": "Use Automatic Configuration Script",
"AUTOSTART": "Start on boot",
+ "AUTOMATICS": "Automatic",
"AUTOUPDATE": "Auto install new updates",
"AUTOUPDATE_DOWNGRADE": "Version not compatible with the server, a downgrade to %1 is needed. Synchronization won't start until then.",
"AUTOUPDATE_UPGRADE": "A new version %1 is available.",
@@ -57,7 +59,7 @@
"CONTEXT_MENU_4": "Upload content",
"CONTINUE": "Continue",
"CONTINUE_USING": "Continue using Drive %1",
- "CREATE": "Create",
+ "CREATE": "create",
"CREATE_REPORT": "Generate bug report",
"DATETIME_FORMAT": "%x %X",
"DAYS": "Day(s)",
@@ -176,12 +178,14 @@
"FEATURE_SYNCHRONIZATION": "Enable or disable the bidirectional synchronization between the local environment and the Nuxeo Platform.\nA restart is needed to apply changes.",
"FEATURE_TASKS_MANAGEMENT": "Handle your tasks from Nuxeo Drive and receive notifications and reminders when a new task is assigned to you.",
"FEEDBACK_LINK": "Something is missing? Share your feedback here.",
+ "FILE": "File",
"FILE_ALREADY_EXISTS": "There is already a file named \"%1\" in this folder. Do you want to replace it with the one you're moving?",
"FILE_ALREADY_EXISTS_HEADER": "A duplicate file has been found.",
"FILE_PATH": "Path: %1",
"FILTERS_WINDOW_TITLE": "%1 - Filters",
"FILTERS_DISABLED": "You must wait for current synchronization actions to be done before filtering some folders.",
"FINALIZING": "Finalizing ...",
+ "FOLDER": "Folder",
"FOLDER_DOES_NOT_EXISTS": "This folder does not exist",
"FOLDER_DUPLICATES_DETECTED": "Duplicate folder detected",
"FOLDER_DUPLICATES_MSG": "The following folder(s) already exist under %2:
Please rename them or process to several transfers within those folders.",
@@ -197,6 +201,7 @@
"HISTORY": "History",
"HOST": "Host",
"HOURS_AGO": "%1 hours ago",
+ "IGNORE": "Ignore",
"IGNORES_SYSTRAY": "Ignored Files (%1)",
"IGNORE_PAIR": "Ignore this error",
"IGNORE_REASON_CORRUPT": "This file is ignored because its integrity cannot be verified.",
@@ -295,11 +300,14 @@
"OPEN_ROOT_FOLDER": "Open %1 folder",
"OPEN_SETTINGS": "Open settings",
"OPEN_WINDOW": "Open window",
+ "ORDERED_FOLDER": "Ordered Folder",
"OTHER": "Other",
+ "OVERRIDE": "Override",
"PASSWORD": "Password",
"PENDING_TASKS": "Review required",
"PERSONAL_SPACE": "Personal space",
"PENDING_TASK_REVIEWS": "New task to review",
+ "PICTURE": "Picture",
"PROXY": "Proxy",
"PROXY_APPLIED": "Proxy settings have been updated",
"PROXY_CHANGE_SETTINGS": "Proxy",
@@ -404,6 +412,7 @@
"USE_SENTRY": "Enable error reporting",
"USERNAME": "Username",
"VALIDATE_DOCUMENT": "Validate the Document %1",
+ "VIDEO": "Video",
"WEB_AUTHENTICATION_WINDOW_TITLE": "Web Authentication",
"WELCOME_MESSAGE": "Set your account and synchronize your files with the Nuxeo Platform.",
"WINDOWS_ERROR_TITLE": "Document error",
diff --git a/nxdrive/gui/constants.py b/nxdrive/gui/constants.py
new file mode 100644
index 0000000000..63224edef6
--- /dev/null
+++ b/nxdrive/gui/constants.py
@@ -0,0 +1,24 @@
+from ..translator import Translator
+
+
+def get_known_types_translations() -> dict:
+ KNOWN_FOLDER_TYPES = {
+ "OrderedFolder": Translator.get("ORDERED_FOLDER"),
+ "Folder": Translator.get("FOLDER"),
+ }
+ KNOWN_FILE_TYPES = {
+ "Audio": Translator.get("AUDIO"),
+ "File": Translator.get("FILE"),
+ "Picture": Translator.get("PICTURE"),
+ "Video": Translator.get("VIDEO"),
+ }
+ DEFAULT_TYPES = {
+ "Automatic": Translator.get("AUTOMATICS"),
+ "Create": Translator.get("CREATE"),
+ }
+
+ return {
+ "FOLDER_TYPES": KNOWN_FOLDER_TYPES,
+ "FILE_TYPES": KNOWN_FILE_TYPES,
+ "DEFAULT": DEFAULT_TYPES,
+ }
diff --git a/nxdrive/gui/folders_dialog.py b/nxdrive/gui/folders_dialog.py
index 016cf93f26..891efbda97 100644
--- a/nxdrive/gui/folders_dialog.py
+++ b/nxdrive/gui/folders_dialog.py
@@ -33,6 +33,7 @@
)
from ..translator import Translator
from ..utils import find_icon, get_tree_list, sizeof_fmt
+from .constants import get_known_types_translations
from .folders_model import FilteredDocuments, FoldersOnly
from .folders_treeview import DocumentTreeView, FolderTreeView
@@ -269,6 +270,11 @@ def __init__(
"dt_last_duplicates_behavior", default="create"
)
+ _types = get_known_types_translations()
+ self.KNOWN_FOLDER_TYPES = _types.get("FOLDER_TYPES", {})
+ self.KNOWN_FILE_TYPES = _types.get("FILE_TYPES", {})
+ self.DEFAULT_TYPES = _types.get("DEFAULT", {})
+
self.vertical_layout.addWidget(self._add_group_local())
self.vertical_layout.addWidget(self._add_group_remote())
self.vertical_layout.addWidget(self._add_group_options())
@@ -407,21 +413,35 @@ def _open_duplicates_doc(self, _: bool) -> None:
"""Open the duplicates management documentation in a browser tab."""
webbrowser.open_new_tab(DOC_URL)
+ def _check_for_known_types(self, is_folder_type: bool, /) -> None:
+ if is_folder_type:
+ for key, val in self.KNOWN_FOLDER_TYPES.items():
+ if key in self.containerTypeList:
+ self.containerTypeList.remove(key)
+ self.containerTypeList.append(val)
+ else:
+ for key, val in self.KNOWN_FILE_TYPES.items():
+ if key in self.docTypeList:
+ self.docTypeList.remove(key)
+ self.docTypeList.append(val)
+
def update_file_group(self, /) -> None:
self.cbDocType.clear()
- self.cbDocType.addItem("Automatic", "create")
+ self.cbContainerType.clear()
+ if values := list(self.DEFAULT_TYPES.values()):
+ self.cbContainerType.addItem(values[0], values[1])
+ self.cbDocType.addItem(values[0], values[1])
if self.remote_folder_ref:
self.docTypeList = self.engine.remote.get_doc_enricher(
self.remote_folder_ref, "subtypes", False
)
-
+ self._check_for_known_types(False)
self.cbDocType.addItems(self.docTypeList)
- self.cbContainerType.clear()
- self.cbContainerType.addItem("Automatic", "create")
if self.remote_folder_ref:
self.containerTypeList = self.engine.remote.get_doc_enricher(
self.remote_folder_ref, "subtypes", True
)
+ self._check_for_known_types(True)
self.cbContainerType.addItems(self.containerTypeList)
def _add_subgroup_doc_type(self, layout: QVBoxLayout, /) -> None:
@@ -509,6 +529,18 @@ def _find_folders_duplicates(self) -> List[str]:
return folders
+ def get_known_type_key(self, is_folder: bool, type: str, /) -> str:
+ if type in self.DEFAULT_TYPES.values():
+ original_list = self.DEFAULT_TYPES
+ else:
+ original_list = (
+ self.KNOWN_FOLDER_TYPES if is_folder else self.KNOWN_FILE_TYPES
+ )
+ try:
+ return list(original_list.keys())[list(original_list.values()).index(type)]
+ except Exception:
+ return type
+
def accept(self) -> None:
"""Action to do when the OK button is clicked."""
super().accept()
@@ -518,9 +550,8 @@ def accept(self) -> None:
if self.cbDocType.currentIndex() == 0
else self.cbDocType.currentText()
)
- folder_duplicates = self._find_folders_duplicates()
- if folder_duplicates:
+ if folder_duplicates := self._find_folders_duplicates():
self.application.folder_duplicate_warning(
folder_duplicates,
self.remote_folder_title,
@@ -535,6 +566,8 @@ def accept(self) -> None:
doc_type = (
self.cbDocType.currentText() if self.cbDocType.currentIndex() != 0 else ""
)
+ doc_type = self.get_known_type_key(False, doc_type)
+ cont_type = self.get_known_type_key(True, cont_type)
self.engine.direct_transfer_async(
self.paths,
self.remote_folder.text(),
diff --git a/tests/functional/test_document_types.py b/tests/functional/test_document_types.py
new file mode 100644
index 0000000000..63a47909bb
--- /dev/null
+++ b/tests/functional/test_document_types.py
@@ -0,0 +1,22 @@
+from pathlib import Path
+
+from nxdrive.gui.constants import get_known_types_translations
+from nxdrive.translator import Translator
+
+
+def get_folder(folder) -> Path:
+ return Path(__file__).parent.parent / "resources" / folder
+
+
+def test_get_known_types_translations():
+ Translator(get_folder("i18n"))
+ assert Translator.locale() == "en"
+ res = get_known_types_translations()
+
+ known_folder_types = res.get("FOLDER_TYPES", {})
+ known_file_types = res.get("FILE_TYPES", {})
+ default_types = res.get("DEFAULT", {})
+
+ assert known_folder_types["Folder"] == Translator.get("FOLDER")
+ assert known_file_types["Audio"] == Translator.get("AUDIO")
+ assert default_types["Automatic"] == Translator.get("AUTOMATICS")