mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	Merge branch 'develop' into renovate/electron-forge-monorepo
This commit is contained in:
		
						commit
						4010cb2789
					
				
							
								
								
									
										25
									
								
								.github/workflows/main-docker.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								.github/workflows/main-docker.yml
									
									
									
									
										vendored
									
									
								
							| @ -100,7 +100,20 @@ jobs: | |||||||
| 
 | 
 | ||||||
|   build: |   build: | ||||||
|     name: Build Docker images |     name: Build Docker images | ||||||
|     runs-on: ubuntu-latest |     strategy: | ||||||
|  |       fail-fast: false | ||||||
|  |       matrix: | ||||||
|  |         include: | ||||||
|  |           - dockerfile: Dockerfile.alpine | ||||||
|  |             platform: linux/amd64 | ||||||
|  |             image: ubuntu-latest | ||||||
|  |           - dockerfile: Dockerfile | ||||||
|  |             platform: linux/arm64 | ||||||
|  |             image: ubuntu-24.04-arm | ||||||
|  |           - dockerfile: Dockerfile | ||||||
|  |             platform: linux/arm/v7 | ||||||
|  |             image: ubuntu-24.04-arm | ||||||
|  |     runs-on: ${{ matrix.image }} | ||||||
|     needs: |     needs: | ||||||
|       - test_docker |       - test_docker | ||||||
|     permissions: |     permissions: | ||||||
| @ -108,16 +121,6 @@ jobs: | |||||||
|       packages: write |       packages: write | ||||||
|       attestations: write |       attestations: write | ||||||
|       id-token: write |       id-token: write | ||||||
|     strategy: |  | ||||||
|       fail-fast: false |  | ||||||
|       matrix: |  | ||||||
|         include: |  | ||||||
|           - dockerfile: Dockerfile.alpine |  | ||||||
|             platform: linux/amd64 |  | ||||||
|           - dockerfile: Dockerfile |  | ||||||
|             platform: linux/arm64 |  | ||||||
|           - dockerfile: Dockerfile |  | ||||||
|             platform: linux/arm/v7 |  | ||||||
|     steps: |     steps: | ||||||
|       - name: Prepare |       - name: Prepare | ||||||
|         run: | |         run: | | ||||||
|  | |||||||
| @ -988,7 +988,7 @@ | |||||||
|   "web_view": { |   "web_view": { | ||||||
|     "web_view": "网页视图", |     "web_view": "网页视图", | ||||||
|     "embed_websites": "网页视图类型的笔记允许您将网站嵌入到 Trilium 中。", |     "embed_websites": "网页视图类型的笔记允许您将网站嵌入到 Trilium 中。", | ||||||
|     "create_label": "首先,请创建一个带有您要嵌入的 URL 地址的标签,例如 #webViewSrc=\"https://www.bing.com\"", |     "create_label": "首先,请创建一个带有您要嵌入的 URL 地址的标签,例如 #webViewSrc=\"https://www.bing.com\"" | ||||||
|   }, |   }, | ||||||
|   "backend_log": { |   "backend_log": { | ||||||
|     "refresh": "刷新" |     "refresh": "刷新" | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ import log from "../../services/log.js"; | |||||||
| import searchService from "../../services/search/services/search.js"; | import searchService from "../../services/search/services/search.js"; | ||||||
| import ValidationError from "../../errors/validation_error.js"; | import ValidationError from "../../errors/validation_error.js"; | ||||||
| import type { Request } from "express"; | import type { Request } from "express"; | ||||||
| import { changeLanguage } from "../../services/i18n.js"; | import { changeLanguage, getLocales } from "../../services/i18n.js"; | ||||||
| import { listSyntaxHighlightingThemes } from "../../services/code_block_theme.js"; | import { listSyntaxHighlightingThemes } from "../../services/code_block_theme.js"; | ||||||
| import type { OptionNames } from "../../services/options_interface.js"; | import type { OptionNames } from "../../services/options_interface.js"; | ||||||
| 
 | 
 | ||||||
| @ -154,37 +154,7 @@ function getSyntaxHighlightingThemes() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getSupportedLocales() { | function getSupportedLocales() { | ||||||
|     // TODO: Currently hardcoded, needs to read the list of available languages.
 |     return getLocales(); | ||||||
|     return [ |  | ||||||
|         { |  | ||||||
|             id: "en", |  | ||||||
|             name: "English" |  | ||||||
|         }, |  | ||||||
|         { |  | ||||||
|             id: "de", |  | ||||||
|             name: "Deutsch" |  | ||||||
|         }, |  | ||||||
|         { |  | ||||||
|             id: "es", |  | ||||||
|             name: "Español" |  | ||||||
|         }, |  | ||||||
|         { |  | ||||||
|             id: "fr", |  | ||||||
|             name: "Français" |  | ||||||
|         }, |  | ||||||
|         { |  | ||||||
|             id: "cn", |  | ||||||
|             name: "简体中文" |  | ||||||
|         }, |  | ||||||
|         { |  | ||||||
|             id: "tw", |  | ||||||
|             name: "繁體中文" |  | ||||||
|         }, |  | ||||||
|         { |  | ||||||
|             id: "ro", |  | ||||||
|             name: "Română" |  | ||||||
|         } |  | ||||||
|     ]; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function isAllowed(name: string) { | function isAllowed(name: string) { | ||||||
|  | |||||||
							
								
								
									
										26
									
								
								src/services/i18n.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/services/i18n.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | |||||||
|  | import { describe, expect, it } from "vitest"; | ||||||
|  | import * as i18n from "./i18n.js"; | ||||||
|  | import path from "path"; | ||||||
|  | import fs from "fs"; | ||||||
|  | 
 | ||||||
|  | function checkTranslations(translationDir: string, translationFileName: string) { | ||||||
|  |     const locales = i18n.getLocales(); | ||||||
|  | 
 | ||||||
|  |     for (const locale of locales) { | ||||||
|  |         const translationPath = path.join(translationDir, locale.id, translationFileName); | ||||||
|  |         const translationFile = fs.readFileSync(translationPath, { encoding: "utf-8" }); | ||||||
|  |         expect(() => { | ||||||
|  |             JSON.parse(translationFile); | ||||||
|  |         }, `JSON error while parsing locale '${locale.id}' at "${translationPath}"`).not.toThrow(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | describe("i18n", () => { | ||||||
|  |     it("frontend translations are valid JSON", () => { | ||||||
|  |         checkTranslations("src/public/translations", "translation.json"); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("backend translations are valid JSON", () => { | ||||||
|  |         checkTranslations("translations", "server.json"); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
| @ -20,6 +20,40 @@ export async function initializeTranslations() { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | export function getLocales() { | ||||||
|  |     // TODO: Currently hardcoded, needs to read the list of available languages.
 | ||||||
|  |     return [ | ||||||
|  |         { | ||||||
|  |             id: "en", | ||||||
|  |             name: "English" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             id: "de", | ||||||
|  |             name: "Deutsch" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             id: "es", | ||||||
|  |             name: "Español" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             id: "fr", | ||||||
|  |             name: "Français" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             id: "cn", | ||||||
|  |             name: "简体中文" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             id: "tw", | ||||||
|  |             name: "繁體中文" | ||||||
|  |         }, | ||||||
|  |         { | ||||||
|  |             id: "ro", | ||||||
|  |             name: "Română" | ||||||
|  |         } | ||||||
|  |     ]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| function getCurrentLanguage() { | function getCurrentLanguage() { | ||||||
|     let language; |     let language; | ||||||
|     if (sql_init.isDbInitialized()) { |     if (sql_init.isDbInitialized()) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran