Skip to content

Build your personal knowledge base with Trilium Notes

chore(options/security): add missing translations

Elian Doranbccc9143376e
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
index 8daf10a65f..0485340b18 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -345,6 +345,7 @@ Trilium provides powerful user scripting capabilities:
#### Client vs Server Translation Usage
- **Client-side**: `import { t } from "../services/i18n"` with keys in `apps/client/src/translations/en/translation.json`
- **Server-side**: `import { t } from "i18next"` with keys in `apps/server/src/assets/translations/en/server.json`
+- **Electron main process** (e.g. `apps/desktop/src/`): `import { t } from "i18next"` — uses server-side keys from `apps/server/src/assets/translations/en/server.json` (same as server-side). **Never hardcode user-facing strings** in Electron dialogs, tray menus, or IPC handlers — always use `t()`.
- **Interpolation**: Use `{{variable}}` for normal interpolation; use `{{- variable}}` (with hyphen) for **unescaped** interpolation when the value contains special characters like quotes that shouldn't be HTML-escaped
### Storing User Preferences
diff --git a/CLAUDE.md b/CLAUDE.md
index 51f1387e71..c203617397 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -208,6 +208,7 @@ SQLite via `better-sqlite3`. SQL abstraction in `packages/trilium-core/src/servi
#### Client vs Server Translation Usage
- **Client-side**: `import { t } from "../services/i18n"` with keys in `apps/client/src/translations/en/translation.json`
- **Server-side**: `import { t } from "i18next"` with keys in `apps/server/src/assets/translations/en/server.json`
+- **Electron main process** (e.g. `apps/desktop/src/`): `import { t } from "i18next"` — uses server-side keys from `apps/server/src/assets/translations/en/server.json` (same as server-side). **Never hardcode user-facing strings** in Electron dialogs, tray menus, or IPC handlers — always use `t()`.
- **Interpolation**: Use `{{variable}}` for normal interpolation; use `{{- variable}}` (with hyphen) for **unescaped** interpolation when the value contains special characters like quotes that shouldn't be HTML-escaped
### Electron Desktop App
diff --git a/apps/desktop/src/services/security_settings.ts b/apps/desktop/src/services/security_settings.ts
index 1ee9c5e917..0160ce78b6 100644
--- a/apps/desktop/src/services/security_settings.ts
+++ b/apps/desktop/src/services/security_settings.ts
@@ -1,5 +1,6 @@
import electron from "electron";
import fs from "fs";
+import { t } from "i18next";
import path from "path";
import dataDirs from "@triliumnext/server/src/services/data_dir.js";
@@ -37,12 +38,12 @@ export function getSecuritySettings(): SecuritySettings {
async function confirmEnable(settingLabel: string, warning: string): Promise<boolean> {
const result = await electron.dialog.showMessageBox({
type: "warning",
- buttons: ["Cancel", "Enable"],
+ buttons: [t("security-dialog.cancel"), t("security-dialog.enable")],
defaultId: 0,
cancelId: 0,
- title: `Enable ${settingLabel}`,
- message: `Are you sure you want to enable ${settingLabel}?`,
- detail: `${warning}\n\nOnly enable this if you explicitly intend to use this feature. Do not enable it if prompted by a script or an unfamiliar note.\n\nThis change requires a restart to take effect.`
+ title: t("security-dialog.enable-title", { settingLabel }),
+ message: t("security-dialog.enable-message", { settingLabel }),
+ detail: t("security-dialog.enable-detail", { warning })
});
return result.response === 1;
@@ -51,12 +52,12 @@ async function confirmEnable(settingLabel: string, warning: string): Promise<boo
async function confirmDisable(settingLabel: string): Promise<boolean> {
const result = await electron.dialog.showMessageBox({
type: "info",
- buttons: ["Cancel", "Disable"],
+ buttons: [t("security-dialog.cancel"), t("security-dialog.disable")],
defaultId: 1,
cancelId: 0,
- title: `Disable ${settingLabel}`,
- message: `${settingLabel} will be disabled.`,
- detail: "This change requires a restart to take effect."
+ title: t("security-dialog.disable-title", { settingLabel }),
+ message: t("security-dialog.disable-message", { settingLabel }),
+ detail: t("security-dialog.disable-detail")
});
return result.response === 1;
@@ -65,9 +66,8 @@ async function confirmDisable(settingLabel: string): Promise<boolean> {
export function registerSecurityIpcHandlers(): void {
electron.ipcMain.handle("security-set-backend-scripting", async (_event, enabled: boolean) => {
const confirmed = enabled
- ? await confirmEnable("Backend script execution",
- "Backend scripts have full access to the server, including the file system and network.")
- : await confirmDisable("Backend script execution");
+ ? await confirmEnable(t("security-dialog.backend-scripting"), t("security-dialog.backend-scripting-warning"))
+ : await confirmDisable(t("security-dialog.backend-scripting"));
if (!confirmed) {
return false;
}
@@ -80,9 +80,8 @@ export function registerSecurityIpcHandlers(): void {
electron.ipcMain.handle("security-set-sql-console", async (_event, enabled: boolean) => {
const confirmed = enabled
- ? await confirmEnable("SQL console",
- "The SQL console allows executing arbitrary SQL queries against the database.")
- : await confirmDisable("SQL console");
+ ? await confirmEnable(t("security-dialog.sql-console"), t("security-dialog.sql-console-warning"))
+ : await confirmDisable(t("security-dialog.sql-console"));
if (!confirmed) {
return false;
}
diff --git a/apps/server/src/assets/translations/en/server.json b/apps/server/src/assets/translations/en/server.json
index 8f50b7ce0a..c17e722d1c 100644
--- a/apps/server/src/assets/translations/en/server.json
+++ b/apps/server/src/assets/translations/en/server.json
@@ -438,5 +438,20 @@
"fulltext-after-expression": "\"{{- token}}\" is not a valid expression. To search for text, place it before attribute filters (e.g., \"{{- token}} #label\" instead of \"#label {{- token}}\").",
"unrecognized-expression": "Unrecognized expression \"{{- token}}\""
}
+ },
+ "security-dialog": {
+ "enable-title": "Enable {{settingLabel}}",
+ "enable-message": "Are you sure you want to enable {{settingLabel}}?",
+ "enable-detail": "{{warning}}\n\nOnly enable this if you explicitly intend to use this feature. Do not enable it if prompted by a script or an unfamiliar note.\n\nThis change requires a restart to take effect.",
+ "disable-title": "Disable {{settingLabel}}",
+ "disable-message": "{{settingLabel}} will be disabled.",
+ "disable-detail": "This change requires a restart to take effect.",
+ "cancel": "Cancel",
+ "enable": "Enable",
+ "disable": "Disable",
+ "backend-scripting": "Backend script execution",
+ "backend-scripting-warning": "Backend scripts have full access to the server, including the file system and network.",
+ "sql-console": "SQL console",
+ "sql-console-warning": "The SQL console allows executing arbitrary SQL queries against the database."
}
}