From c25c8c753de646e010add4f51759c902f55d5d07 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 8 Sep 2024 18:12:16 +0300 Subject: [PATCH] server: Translate login page --- src/app.ts | 6 ++++++ src/views/login.ejs | 12 ++++++------ translations/en/server.json | 8 ++++++++ translations/ro/server.json | 8 ++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/app.ts b/src/app.ts index 351bd6f0a..4fabebcc5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -14,6 +14,7 @@ import custom from "./routes/custom.js"; import error_handlers from "./routes/error_handlers.js"; import { startScheduledCleanup } from "./services/erase.js"; import sql_init from "./services/sql_init.js"; +import { t } from "i18next"; await import('./services/handlers.js'); await import('./becca/becca_loader.js'); @@ -29,6 +30,11 @@ sql_init.initializeDb(); app.set('views', path.join(scriptDir, 'views')); app.set('view engine', 'ejs'); +app.use((req, res, next) => { + res.locals.t = t; + return next(); +}); + if (!utils.isElectron()) { app.use(compression()); // HTTP compression } diff --git a/src/views/login.ejs b/src/views/login.ejs index 34aa0c732..be01bd623 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -3,24 +3,24 @@ - Login + <%= t("login.title") %>
-

Trilium login

+

<%= t("login.heading") %>

<% if (failedAuth) { %>
- Password is incorrect. Please try again. + <%= t("login.incorrect-password") %>
<% } %>
- +
@@ -28,12 +28,12 @@
- +
diff --git a/translations/en/server.json b/translations/en/server.json index a7129796d..15211f1d9 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -90,5 +90,13 @@ "force-save-revision": "Force creating / saving new note revision of the active note", "show-help": "Shows built-in Help / cheatsheet", "toggle-book-properties": "Toggle Book Properties" + }, + "login": { + "title": "Login", + "heading": "Trilium login", + "incorrect-password": "Password is incorrect. Please try again.", + "password": "Password", + "remember-me": "Remember me", + "button": "Login" } } diff --git a/translations/ro/server.json b/translations/ro/server.json index 62414fd60..ef9abe6a6 100644 --- a/translations/ro/server.json +++ b/translations/ro/server.json @@ -93,5 +93,13 @@ "unhoist": "Defocalizează complet", "zoom-in": "Mărește zoom-ul", "zoom-out": "Micșorează zoom-ul" + }, + "login": { + "button": "Autentifică", + "heading": "Autentificare în Trilium", + "incorrect-password": "Parola nu este corectă. Încercați din nou.", + "password": "Parolă", + "remember-me": "Ține-mă minte", + "title": "Autentificare" } }