server: Translate login page

This commit is contained in:
Elian Doran 2024-09-08 18:12:16 +03:00
parent 317b7b4c59
commit c25c8c753d
No known key found for this signature in database
4 changed files with 28 additions and 6 deletions

View File

@ -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
}

View File

@ -3,24 +3,24 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Login</title>
<title><%= t("login.title") %></title>
<link rel="apple-touch-icon" sizes="180x180" href="<%= assetPath %>/images/app-icons/ios/apple-touch-icon.png">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div class="container">
<div class="col-xs-12 col-sm-10 col-md-6 col-lg-4 col-xl-4 mx-auto" style="padding-top: 25px;">
<h1>Trilium login</h1>
<h1><%= t("login.heading") %></h1>
<% if (failedAuth) { %>
<div class="alert alert-warning">
Password is incorrect. Please try again.
<%= t("login.incorrect-password") %>
</div>
<% } %>
<form action="login" method="POST">
<div class="form-group">
<label for="password">Password</label>
<label for="password"><%= t("login.password") %></label>
<div class="controls">
<input id="password" name="password" placeholder="" class="form-control" type="password">
</div>
@ -28,12 +28,12 @@
<div class="form-group">
<div class="checkbox">
<label>
<input id="remember-me" name="rememberMe" value="1" type="checkbox"> Remember me
<input id="remember-me" name="rememberMe" value="1" type="checkbox"> <%= t("login.remember-me") %>
</label>
</div>
</div>
<div class="form-group">
<button class="btn btn-success">Login</button>
<button class="btn btn-success"><%= t("login.button") %></button>
</div>
</form>
</div>

View File

@ -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"
}
}

View File

@ -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"
}
}