Skip to content

Build your personal knowledge base with Trilium Notes

i18n: Translate protected session

Elian Doranae593ea36380
diff --git a/src/public/app/services/protected_session.js b/src/public/app/services/protected_session.js
index cf52639b47..e221e0d202 100644
--- a/src/public/app/services/protected_session.js
+++ b/src/public/app/services/protected_session.js
@@ -6,6 +6,7 @@ import appContext from "../components/app_context.js";
import froca from "./froca.js";
import utils from "./utils.js";
import options from "./options.js";
+import { t } from './i18n.js';
let protectedSessionDeferred = null;
@@ -85,10 +86,10 @@ async function protectNote(noteId, protect, includingSubtree) {
await server.put(`notes/${noteId}/protect/${protect ? 1 : 0}?subtree=${includingSubtree ? 1 : 0}`);
}
-function makeToast(message, protectingLabel, text) {
+function makeToast(message, title, text) {
return {
id: message.taskId,
- title: `${protectingLabel} status`,
+ title,
message: text,
icon: message.data.protect ? "check-shield" : "shield"
};
@@ -99,15 +100,19 @@ ws.subscribeToMessages(async message => {
return;
}
- const protectingLabel = message.data.protect ? "Protecting" : "Unprotecting";
-
+ const isProtecting = message.data.protect;
+ const title = isProtecting ? t("protected_session.protecting-title") : t("protected_session.unprotecting-title");
+
if (message.type === 'taskError') {
toastService.closePersistent(message.taskId);
toastService.showError(message.message);
} else if (message.type === 'taskProgressCount') {
- toastService.showPersistent(makeToast(message, protectingLabel,`${protectingLabel} in progress: ${message.progressCount}`));
+ const count = message.progressCount;
+ const text = ( isProtecting ? t("protected_session.protecting-in-progress", { count }) : t("protected_session.unprotecting-in-progress-count", { count }));
+ toastService.showPersistent(makeToast(message, title, text));
} else if (message.type === 'taskSucceeded') {
- const toast = makeToast(message, protectingLabel, `${protectingLabel} finished successfully.`);
+ const text = (isProtecting ? t("protected_session.protecting-finished-successfully") : t("protected_session.unprotecting-finished-successfully"))
+ const toast = makeToast(message, title, text);
toast.closeAfter = 3000;
toastService.showPersistent(toast);
diff --git a/src/public/translations/en/translation.json b/src/public/translations/en/translation.json
index 8f35f177be..b5d4de3861 100644
--- a/src/public/translations/en/translation.json
+++ b/src/public/translations/en/translation.json
@@ -926,7 +926,13 @@
"enter_password_instruction": "Showing protected note requires entering your password:",
"start_session_button": "Start protected session",
"started": "Protected session has been started.",
- "wrong_password": "Wrong password."
+ "wrong_password": "Wrong password.",
+ "protecting-finished-successfully": "Protecting finished successfully.",
+ "unprotecting-finished-successfully": "Unprotecting finished successfully.",
+ "protecting-in-progress": "Protecting in progress: {{count}}",
+ "unprotecting-in-progress-count": "Unprotecting in progress: {{count}}",
+ "protecting-title": "Protecting status",
+ "unprotecting-title": "Unprotecting status"
},
"relation_map": {
"open_in_new_tab": "Open in new tab",
diff --git a/src/public/translations/ro/translation.json b/src/public/translations/ro/translation.json
index de59c8c507..902215f08c 100644
--- a/src/public/translations/ro/translation.json
+++ b/src/public/translations/ro/translation.json
@@ -908,7 +908,13 @@
"enter_password_instruction": "Afișarea notițelor protejate necesită introducerea parolei:",
"start_session_button": "Deschide sesiunea protejată",
"started": "Sesiunea protejată este activă.",
- "wrong_password": "Parolă greșită."
+ "wrong_password": "Parolă greșită.",
+ "protecting-finished-successfully": "Protejarea a avut succes.",
+ "protecting-in-progress": "Protejare în curs: {{count}}",
+ "protecting-title": "Stare protejare",
+ "unprotecting-title": "Stare deprotejare",
+ "unprotecting-finished-successfully": "Deprotejarea a avut succes.",
+ "unprotecting-in-progress-count": "Deprotejare în curs: {{count}}"
},
"protected_session_password": {
"close_label": "Închide",