mirror of
https://github.com/zadam/trilium.git
synced 2025-11-10 07:15:51 +01:00
server: Set up early initialization of i18n
This commit is contained in:
26
src/main.ts
Normal file
26
src/main.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import i18next from "i18next";
|
||||
import Backend from "i18next-fs-backend";
|
||||
/*
|
||||
* Make sure not to import any modules that depend on localized messages via i18next here, as the initializations
|
||||
* are loaded later and will result in an empty string.
|
||||
*/
|
||||
|
||||
async function initializeTranslations() {
|
||||
// Initialize translations
|
||||
await i18next.use(Backend).init({
|
||||
lng: "ro",
|
||||
fallbackLng: "en",
|
||||
ns: "server",
|
||||
backend: {
|
||||
loadPath: "translations/{{lng}}/{{ns}}.json"
|
||||
},
|
||||
debug: true
|
||||
});
|
||||
}
|
||||
|
||||
async function startApplication() {
|
||||
await import("./www.js");
|
||||
}
|
||||
|
||||
await initializeTranslations();
|
||||
await startApplication();
|
||||
@@ -4,6 +4,7 @@ import optionService from "./options.js";
|
||||
import log from "./log.js";
|
||||
import utils from "./utils.js";
|
||||
import { KeyboardShortcut } from './keyboard_actions_interface.js';
|
||||
import { t } from "i18next";
|
||||
|
||||
const isMac = process.platform === "darwin";
|
||||
const isElectron = utils.isElectron();
|
||||
@@ -19,7 +20,7 @@ const isElectron = utils.isElectron();
|
||||
|
||||
const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
|
||||
{
|
||||
separator: "Note navigation"
|
||||
separator: t("keyboard-actions.note-navigation")
|
||||
},
|
||||
{
|
||||
actionName: "backInNoteHistory",
|
||||
|
||||
16
src/www.ts
16
src/www.ts
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import app from "./app.js";
|
||||
import sessionParser from "./routes/session_parser.js";
|
||||
import fs from "fs";
|
||||
@@ -12,8 +13,6 @@ import utils from "./services/utils.js";
|
||||
import port from "./services/port.js";
|
||||
import host from "./services/host.js";
|
||||
import semver from "semver";
|
||||
import i18next from "i18next";
|
||||
import Backend from "i18next-fs-backend";
|
||||
|
||||
// setup basic error handling even before requiring dependencies, since those can produce errors as well
|
||||
|
||||
@@ -57,18 +56,7 @@ async function startTrilium() {
|
||||
*/
|
||||
if (utils.isElectron()) {
|
||||
(await import('electron')).app.requestSingleInstanceLock();
|
||||
}
|
||||
|
||||
// Initialize translations
|
||||
i18next.use(Backend).init({
|
||||
lng: "ro",
|
||||
fallbackLng: "en",
|
||||
ns: "server",
|
||||
backend: {
|
||||
loadPath: "translations/{{lng}}/{{ns}}.json"
|
||||
},
|
||||
debug: true
|
||||
});
|
||||
}
|
||||
|
||||
log.info(JSON.stringify(appInfo, null, 2));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user