Merge branch 'develop' into renovate/vitest-monorepo

This commit is contained in:
Elian Doran 2025-02-20 17:35:38 +02:00 committed by GitHub
commit f83beafd76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 101 additions and 68 deletions

View File

@ -100,7 +100,20 @@ jobs:
build:
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:
- test_docker
permissions:
@ -108,16 +121,6 @@ jobs:
packages: write
attestations: 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:
- name: Prepare
run: |

View File

@ -988,7 +988,7 @@
"web_view": {
"web_view": "网页视图",
"embed_websites": "网页视图类型的笔记允许您将网站嵌入到 Trilium 中。",
"create_label": "首先,请创建一个带有您要嵌入的 URL 地址的标签,例如 #webViewSrc=\"https://www.bing.com\"",
"create_label": "首先,请创建一个带有您要嵌入的 URL 地址的标签,例如 #webViewSrc=\"https://www.bing.com\""
},
"backend_log": {
"refresh": "刷新"

View File

@ -5,7 +5,7 @@ import log from "../../services/log.js";
import searchService from "../../services/search/services/search.js";
import ValidationError from "../../errors/validation_error.js";
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 type { OptionNames } from "../../services/options_interface.js";
@ -154,37 +154,7 @@ function getSyntaxHighlightingThemes() {
}
function getSupportedLocales() {
// 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ă"
}
];
return getLocales();
}
function isAllowed(name: string) {

26
src/services/i18n.spec.ts Normal file
View 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");
});
});

View File

@ -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() {
let language;
if (sql_init.isDbInitialized()) {