mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	electron: Fix loading of i18n
This commit is contained in:
		
							parent
							
								
									d00c028a0c
								
							
						
					
					
						commit
						68042994e0
					
				@ -22,7 +22,7 @@ rm -r $PKG_DIR/node/lib/node_modules/npm
 | 
			
		||||
rm -r $PKG_DIR/node/include/node
 | 
			
		||||
 | 
			
		||||
rm -r $PKG_DIR/node_modules/electron*
 | 
			
		||||
rm -r $PKG_DIR/electron.js
 | 
			
		||||
rm -r $PKG_DIR/electron*.js
 | 
			
		||||
 | 
			
		||||
printf "#!/bin/sh\n./node/bin/node src/www" > $PKG_DIR/trilium.sh
 | 
			
		||||
chmod 755 $PKG_DIR/trilium.sh
 | 
			
		||||
 | 
			
		||||
@ -37,11 +37,11 @@ for f in 'package.json' 'package-lock.json' 'README.md' 'LICENSE' 'config-sample
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# Patch package.json main
 | 
			
		||||
sed -i 's/.\/dist\/electron.js/electron.js/g' "$DIR/package.json"
 | 
			
		||||
sed -i 's/.\/dist\/electron-main.js/electron-main.js/g' "$DIR/package.json"
 | 
			
		||||
 | 
			
		||||
script_dir=$(realpath $(dirname $0))
 | 
			
		||||
cp -R "$script_dir/../build/src" "$DIR"
 | 
			
		||||
cp "$script_dir/../build/electron.js" "$DIR"
 | 
			
		||||
cp "$script_dir/../build/electron-main.js" "$DIR"
 | 
			
		||||
 | 
			
		||||
# run in subshell (so we return to original dir)
 | 
			
		||||
(cd $DIR && npm install --omit=dev)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								electron-main.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								electron-main.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
import { initializeTranslations } from "./src/services/i18n.js";
 | 
			
		||||
 | 
			
		||||
await initializeTranslations();
 | 
			
		||||
await import("./electron.js")
 | 
			
		||||
							
								
								
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -99,7 +99,7 @@
 | 
			
		||||
        "yauzl": "^3.1.3"
 | 
			
		||||
      },
 | 
			
		||||
      "bin": {
 | 
			
		||||
        "trilium": "src/www.js"
 | 
			
		||||
        "trilium": "src/main.js"
 | 
			
		||||
      },
 | 
			
		||||
      "devDependencies": {
 | 
			
		||||
        "@electron-forge/cli": "^7.4.0",
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
  "description": "Build your personal knowledge base with TriliumNext Notes",
 | 
			
		||||
  "version": "0.90.6-beta",
 | 
			
		||||
  "license": "AGPL-3.0-only",
 | 
			
		||||
  "main": "./dist/electron.js",
 | 
			
		||||
  "main": "./dist/electron-main.js",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "TriliumNext Notes Team",
 | 
			
		||||
    "email": "contact@eliandoran.me",
 | 
			
		||||
@ -25,7 +25,7 @@
 | 
			
		||||
    "start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/main.ts",
 | 
			
		||||
    "start-test-server": "npm run switch-server; rimraf ./data-test; cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data-test TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev TRILIUM_PORT=9999 ts-node src/main.ts",
 | 
			
		||||
    "qstart-server": "npm run switch-server && npm run start-server",
 | 
			
		||||
    "start-electron": "npm run prepare-dist && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron.js --inspect=5858 .",
 | 
			
		||||
    "start-electron": "npm run prepare-dist && cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 TRILIUM_ENV=dev electron ./dist/electron-main.js --inspect=5858 .",
 | 
			
		||||
    "start-electron-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 electron --inspect=5858 .",
 | 
			
		||||
    "qstart-electron": "npm run switch-electron && npm run start-electron",
 | 
			
		||||
    "switch-server": "rimraf ./node_modules/better-sqlite3 && npm install",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/main.ts
									
									
									
									
									
								
							@ -1,22 +1,9 @@
 | 
			
		||||
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
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
import { initializeTranslations } from "./services/i18n.js";
 | 
			
		||||
 | 
			
		||||
async function startApplication() {
 | 
			
		||||
    await import("./www.js");
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								src/services/i18n.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/services/i18n.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
import i18next from "i18next";
 | 
			
		||||
import Backend from "i18next-fs-backend";
 | 
			
		||||
 | 
			
		||||
export async function initializeTranslations() {
 | 
			
		||||
  // Initialize translations
 | 
			
		||||
  await i18next.use(Backend).init({
 | 
			
		||||
      lng: "ro",
 | 
			
		||||
      fallbackLng: "en",
 | 
			
		||||
      ns: "server",
 | 
			
		||||
      backend: {
 | 
			
		||||
          loadPath: "translations/{{lng}}/{{ns}}.json"
 | 
			
		||||
      },
 | 
			
		||||
      debug: true
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user