From d014ae4fcf61b99040aca067711aa61c93f089e0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 14:23:48 +0200 Subject: [PATCH 1/8] chore(ckeditor5): set up dependency to commons --- packages/ckeditor5/package.json | 1 + pnpm-lock.yaml | 57 ++------------------------------- 2 files changed, 4 insertions(+), 54 deletions(-) diff --git a/packages/ckeditor5/package.json b/packages/ckeditor5/package.json index a97c1079b..cf2dc5fde 100644 --- a/packages/ckeditor5/package.json +++ b/packages/ckeditor5/package.json @@ -6,6 +6,7 @@ "type": "module", "main": "./src/index.ts", "dependencies": { + "@triliumnext/commons": "workspace:*", "@triliumnext/ckeditor5-admonition": "workspace:*", "@triliumnext/ckeditor5-footnotes": "workspace:*", "@triliumnext/ckeditor5-keyboard-marker": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c422288ce..89e346f04 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -856,6 +856,9 @@ importers: '@triliumnext/ckeditor5-mermaid': specifier: workspace:* version: link:../ckeditor5-mermaid + '@triliumnext/commons': + specifier: workspace:* + version: link:../commons ckeditor5: specifier: 47.2.0 version: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) @@ -15543,8 +15546,6 @@ snapshots: '@ckeditor/ckeditor5-core': 47.2.0 '@ckeditor/ckeditor5-upload': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-ai@47.2.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)': dependencies: @@ -15615,8 +15616,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-block-quote@47.2.0': dependencies: @@ -15627,8 +15626,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-bookmark@47.2.0': dependencies: @@ -15639,8 +15636,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 '@ckeditor/ckeditor5-widget': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-case-change@47.2.0': dependencies: @@ -15691,8 +15686,6 @@ snapshots: '@ckeditor/ckeditor5-core': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-code-block@47.2.0(patch_hash=2361d8caad7d6b5bddacc3a3b4aa37dbfba260b1c1b22a450413a79c1bb1ce95)': dependencies: @@ -15926,8 +15919,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-editor-classic@47.2.0': dependencies: @@ -15937,8 +15928,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-editor-decoupled@47.2.0': dependencies: @@ -15948,8 +15937,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-editor-inline@47.2.0': dependencies: @@ -15959,8 +15946,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-editor-multi-root@47.2.0': dependencies: @@ -15983,8 +15968,6 @@ snapshots: '@ckeditor/ckeditor5-table': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-emoji@47.2.0': dependencies: @@ -15997,8 +15980,6 @@ snapshots: ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 fuzzysort: 3.1.0 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-engine@47.2.0': dependencies: @@ -16041,8 +16022,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-export-word@47.2.0': dependencies: @@ -16067,8 +16046,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-font@47.2.0': dependencies: @@ -16110,8 +16087,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-heading@47.2.0': dependencies: @@ -16122,8 +16097,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-highlight@47.2.0': dependencies: @@ -16143,8 +16116,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 '@ckeditor/ckeditor5-widget': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-html-embed@47.2.0': dependencies: @@ -16171,8 +16142,6 @@ snapshots: '@ckeditor/ckeditor5-widget': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-icons@47.2.0': {} @@ -16204,8 +16173,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-indent@47.2.0': dependencies: @@ -16342,8 +16309,6 @@ snapshots: '@ckeditor/ckeditor5-widget': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-minimap@47.2.0': dependencies: @@ -16436,8 +16401,6 @@ snapshots: '@ckeditor/ckeditor5-paste-from-office': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-paste-from-office@47.2.0': dependencies: @@ -16445,8 +16408,6 @@ snapshots: '@ckeditor/ckeditor5-core': 47.2.0 '@ckeditor/ckeditor5-engine': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-real-time-collaboration@47.2.0(bufferutil@4.0.9)(utf-8-validate@6.0.5)': dependencies: @@ -16477,8 +16438,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-restricted-editing@47.2.0': dependencies: @@ -16488,8 +16447,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-revision-history@47.2.0': dependencies: @@ -16567,8 +16524,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-special-characters@47.2.0': dependencies: @@ -16578,8 +16533,6 @@ snapshots: '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-style@47.2.0': dependencies: @@ -16682,8 +16635,6 @@ snapshots: '@ckeditor/ckeditor5-icons': 47.2.0 '@ckeditor/ckeditor5-ui': 47.2.0 '@ckeditor/ckeditor5-utils': 47.2.0 - transitivePeerDependencies: - - supports-color '@ckeditor/ckeditor5-upload@47.2.0': dependencies: @@ -16741,8 +16692,6 @@ snapshots: '@ckeditor/ckeditor5-utils': 47.2.0 ckeditor5: 47.2.0(patch_hash=8331a09d41443b39ea1c784daaccfeb0da4f9065ed556e7de92e9c77edd9eb41) es-toolkit: 1.39.5 - transitivePeerDependencies: - - supports-color '@codemirror/autocomplete@6.18.6': dependencies: From a10d99f93870d01e654c24c0b50dc464aecdb16e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 14:24:07 +0200 Subject: [PATCH 2/8] feat(ckeditor5): set up multi-language support --- .../text/CKEditorWithWatchdog.tsx | 7 +- .../src/widgets/type_widgets/text/config.ts | 10 +-- packages/ckeditor5/src/i18n.ts | 90 +++++++++++++++++++ packages/ckeditor5/src/index.ts | 1 + 4 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 packages/ckeditor5/src/i18n.ts diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx index b7346dd9a..fd6814528 100644 --- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx +++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx @@ -1,9 +1,10 @@ import { HTMLProps, RefObject, useEffect, useImperativeHandle, useRef, useState } from "preact/compat"; import { PopupEditor, ClassicEditor, EditorWatchdog, type WatchdogConfig, CKTextEditor, TemplateDefinition } from "@triliumnext/ckeditor5"; import { buildConfig, BuildEditorOptions } from "./config"; -import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef } from "../../react/hooks"; +import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef, useTriliumOption } from "../../react/hooks"; import link from "../../../services/link"; import froca from "../../../services/froca"; +import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons"; export type BoxSize = "small" | "medium" | "full"; @@ -37,6 +38,7 @@ interface CKEditorWithWatchdogProps extends Pick, "cla export default function CKEditorWithWatchdog({ containerRef: externalContainerRef, content, contentLanguage, className, tabIndex, isClassicEditor, watchdogRef: externalWatchdogRef, watchdogConfig, onNotificationWarning, onWatchdogStateChange, onChange, onEditorInitialized, editorApi, templates }: CKEditorWithWatchdogProps) { const containerRef = useSyncedRef(externalContainerRef, null); const watchdogRef = useRef(null); + const [ uiLanguage ] = useTriliumOption("locale"); const [ editor, setEditor ] = useState(); const { parentComponent } = useNoteContext(); @@ -156,6 +158,7 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe const editor = await buildEditor(container, !!isClassicEditor, { forceGplLicense: false, isClassicEditor: !!isClassicEditor, + uiLanguage: uiLanguage as DISPLAYABLE_LOCALE_IDS, contentLanguage: contentLanguage ?? null, templates }); @@ -180,7 +183,7 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe watchdog.create(container); return () => watchdog.destroy(); - }, [ contentLanguage, templates ]); + }, [ contentLanguage, templates, uiLanguage ]); // React to content changes. useEffect(() => editor?.setData(content ?? ""), [ editor, content ]); diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.ts index 7f39c4ea2..a12d384ef 100644 --- a/apps/client/src/widgets/type_widgets/text/config.ts +++ b/apps/client/src/widgets/type_widgets/text/config.ts @@ -1,5 +1,5 @@ -import { ALLOWED_PROTOCOLS, MIME_TYPE_AUTO } from "@triliumnext/commons"; -import { buildExtraCommands, type EditorConfig, PREMIUM_PLUGINS, TemplateDefinition } from "@triliumnext/ckeditor5"; +import { ALLOWED_PROTOCOLS, DISPLAYABLE_LOCALE_IDS, MIME_TYPE_AUTO } from "@triliumnext/commons"; +import { buildExtraCommands, type EditorConfig, getCkLocale, PREMIUM_PLUGINS, TemplateDefinition } from "@triliumnext/ckeditor5"; import { getHighlightJsNameForMime } from "../../../services/mime_types.js"; import options from "../../../services/options.js"; import { ensureMimeTypesForHighlighting, isSyntaxHighlightEnabled } from "../../../services/syntax_highlight.js"; @@ -17,6 +17,7 @@ export const OPEN_SOURCE_LICENSE_KEY = "GPL"; export interface BuildEditorOptions { forceGplLicense: boolean; isClassicEditor: boolean; + uiLanguage: DISPLAYABLE_LOCALE_IDS; contentLanguage: string | null; templates: TemplateDefinition[]; } @@ -161,9 +162,8 @@ export async function buildConfig(opts: BuildEditorOptions): Promise Promise<{ default: Translations }>; + premiumFeaturesTranslation: () => Promise<{ default: Translations }>; +} + +const LOCALE_MAPPINGS: Record = { + en: null, + en_rtl: null, + ar: { + languageCode: "ar", + coreTranslation: () => import("ckeditor5/translations/ar.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/ar.js"), + }, + cn: { + languageCode: "zh", + coreTranslation: () => import("ckeditor5/translations/zh-cn.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/zh-cn.js"), + }, + de: { + languageCode: "de", + coreTranslation: () => import("ckeditor5/translations/de.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/de.js"), + }, + es: { + languageCode: "es", + coreTranslation: () => import("ckeditor5/translations/es.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/es.js"), + }, + fr: { + languageCode: "fr", + coreTranslation: () => import("ckeditor5/translations/fr.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/fr.js"), + }, + it: { + languageCode: "it", + coreTranslation: () => import("ckeditor5/translations/it.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/it.js"), + }, + ja: { + languageCode: "ja", + coreTranslation: () => import("ckeditor5/translations/ja.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/ja.js"), + }, + pt: { + languageCode: "pt", + coreTranslation: () => import("ckeditor5/translations/pt.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/pt.js"), + }, + pt_br: { + languageCode: "pt-br", + coreTranslation: () => import("ckeditor5/translations/pt-br.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/pt-br.js"), + }, + ro: { + languageCode: "ro", + coreTranslation: () => import("ckeditor5/translations/ro.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/ro.js"), + }, + tw: { + languageCode: "zh-tw", + coreTranslation: () => import("ckeditor5/translations/zh.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/zh.js"), + }, + uk: { + languageCode: "uk", + coreTranslation: () => import("ckeditor5/translations/uk.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/uk.js"), + }, + ru: { + languageCode: "ru", + coreTranslation: () => import("ckeditor5/translations/ru.js"), + premiumFeaturesTranslation: () => import("ckeditor5-premium-features/translations/ru.js") + }, +}; + +export default async function getCkLocale(locale: DISPLAYABLE_LOCALE_IDS): Promise> { + const mapping = LOCALE_MAPPINGS[locale]; + if (!mapping) return {}; + + const coreTranslation = (await (mapping.coreTranslation())).default; + const premiumFeaturesTranslation = (await (mapping.premiumFeaturesTranslation())).default; + return { + language: mapping.languageCode, + translations: [ coreTranslation, premiumFeaturesTranslation ] + }; +} diff --git a/packages/ckeditor5/src/index.ts b/packages/ckeditor5/src/index.ts index 1f7be24e4..2d73ecdea 100644 --- a/packages/ckeditor5/src/index.ts +++ b/packages/ckeditor5/src/index.ts @@ -8,6 +8,7 @@ export { PREMIUM_PLUGINS } from "./plugins.js"; export type { EditorConfig, MentionFeed, MentionFeedObjectItem, ModelNode, ModelPosition, ModelElement, WatchdogConfig, WatchdogState } from "ckeditor5"; export type { TemplateDefinition } from "ckeditor5-premium-features"; export { default as buildExtraCommands } from "./extra_slash_commands.js"; +export { default as getCkLocale } from "./i18n.js"; // Import with sideffects to ensure that type augmentations are present. import "@triliumnext/ckeditor5-math"; From 89228f264fa74dbdfa12f1edf8944d49a1096ab0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 17:34:56 +0200 Subject: [PATCH 3/8] feat(mindmap): add support for locales --- .../src/widgets/type_widgets/MindMap.tsx | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/MindMap.tsx b/apps/client/src/widgets/type_widgets/MindMap.tsx index 4b3c8fe0d..715612947 100644 --- a/apps/client/src/widgets/type_widgets/MindMap.tsx +++ b/apps/client/src/widgets/type_widgets/MindMap.tsx @@ -1,15 +1,16 @@ import { useCallback, useEffect, useRef } from "preact/hooks"; import { TypeWidgetProps } from "./type_widget"; -import { MindElixirData, MindElixirInstance, Operation, default as VanillaMindElixir } from "mind-elixir"; +import { MindElixirData, MindElixirInstance, Operation, Options, default as VanillaMindElixir } from "mind-elixir"; import { HTMLAttributes, RefObject } from "preact"; // allow node-menu plugin css to be bundled by webpack import nodeMenu from "@mind-elixir/node-menu"; import "mind-elixir/style"; import "@mind-elixir/node-menu/dist/style.css"; import "./MindMap.css"; -import { useEditorSpacedUpdate, useNoteLabelBoolean, useSyncedRef, useTriliumEvent, useTriliumEvents } from "../react/hooks"; +import { useEditorSpacedUpdate, useNoteLabelBoolean, useSyncedRef, useTriliumEvent, useTriliumEvents, useTriliumOption } from "../react/hooks"; import { refToJQuerySelector } from "../react/react_utils"; import utils from "../../services/utils"; +import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons"; const NEW_TOPIC_NAME = ""; @@ -21,6 +22,24 @@ interface MindElixirProps { onChange?: () => void; } +const LOCALE_MAPPINGS: Record = { + ar: null, + cn: "zh_CN", + de: null, + en: "en", + en_rtl: "en", + es: "es", + fr: "fr", + it: "it", + ja: "ja", + pt: "pt", + pt_br: "pt", + ro: null, + ru: "ru", + tw: "zh_TW", + uk: null +}; + export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) { const apiRef = useRef(null); const containerRef = useRef(null); @@ -110,12 +129,14 @@ export default function MindMap({ note, ntxId, noteContext }: TypeWidgetProps) { function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef: externalApiRef, onChange, editable }: MindElixirProps) { const containerRef = useSyncedRef(externalContainerRef, null); const apiRef = useRef(null); + const [ locale ] = useTriliumOption("locale"); function reinitialize() { if (!containerRef.current) return; const mind = new VanillaMindElixir({ el: containerRef.current, + locale: LOCALE_MAPPINGS[locale], editable }); @@ -143,7 +164,7 @@ function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef if (data) { apiRef.current?.init(data); } - }, [ editable ]); + }, [ editable, locale ]); // On change listener. useEffect(() => { From 7d1453ffbdb9e6bdd2ac8be68cd58e38e21d2102 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 17:49:55 +0200 Subject: [PATCH 4/8] feat(canvas): add support for locales --- .../widgets/type_widgets/canvas/Canvas.tsx | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx b/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx index 79f7f3795..968c5c994 100644 --- a/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx +++ b/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx @@ -1,7 +1,7 @@ import { Excalidraw } from "@excalidraw/excalidraw"; import { TypeWidgetProps } from "../type_widget"; import "@excalidraw/excalidraw/index.css"; -import { useNoteLabelBoolean } from "../../react/hooks"; +import { useNoteLabelBoolean, useTriliumOption } from "../../react/hooks"; import { useCallback, useMemo, useRef } from "preact/hooks"; import { type ExcalidrawImperativeAPI, type AppState } from "@excalidraw/excalidraw/types"; import options from "../../../services/options"; @@ -9,11 +9,30 @@ import "./Canvas.css"; import { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types"; import { goToLinkExt } from "../../../services/link"; import useCanvasPersistence from "./persistence"; +import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons"; // currently required by excalidraw, in order to allows self-hosting fonts locally. // this avoids making excalidraw load the fonts from an external CDN. window.EXCALIDRAW_ASSET_PATH = `${window.location.pathname}/node_modules/@excalidraw/excalidraw/dist/prod`; +const LANGUAGE_MAPPINGS: Record = { + ar: "ar-SA", + cn: "zh-CN", + de: "de-DE", + en: "en", + en_rtl: "en", + es: "es-ES", + fr: "fr-FR", + it: "it-IT", + ja: "ja-JP", + pt: "pt-PT", + pt_br: "pt-BR", + ro: "ro-RO", + ru: "ru-RU", + tw: "zh-TW", + uk: "uk-UA" +}; + export default function Canvas({ note, noteContext }: TypeWidgetProps) { const apiRef = useRef(null); const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly"); @@ -21,6 +40,7 @@ export default function Canvas({ note, noteContext }: TypeWidgetProps) { const documentStyle = window.getComputedStyle(document.documentElement); return documentStyle.getPropertyValue("--theme-style")?.trim() as AppState["theme"]; }, []); + const [ locale ] = useTriliumOption("locale"); const persistence = useCanvasPersistence(note, noteContext, apiRef, themeStyle, isReadOnly); /** Use excalidraw's native zoom instead of the global zoom. */ @@ -58,6 +78,7 @@ export default function Canvas({ note, noteContext }: TypeWidgetProps) { detectScroll={false} handleKeyboardGlobally={false} autoFocus={false} + langCode={LANGUAGE_MAPPINGS[locale]} UIOptions={{ canvasActions: { saveToActiveFile: false, From 497bb352098ecc2f092a5304733207850baae243 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 21:03:53 +0200 Subject: [PATCH 5/8] test(canvas): test all languages are mapped correctly --- .../widgets/type_widgets/canvas/Canvas.tsx | 20 +------------ .../widgets/type_widgets/canvas/i18n.spec.ts | 29 +++++++++++++++++++ .../src/widgets/type_widgets/canvas/i18n.ts | 19 ++++++++++++ 3 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 apps/client/src/widgets/type_widgets/canvas/i18n.spec.ts create mode 100644 apps/client/src/widgets/type_widgets/canvas/i18n.ts diff --git a/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx b/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx index 968c5c994..fb5cc1df5 100644 --- a/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx +++ b/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx @@ -9,30 +9,12 @@ import "./Canvas.css"; import { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types"; import { goToLinkExt } from "../../../services/link"; import useCanvasPersistence from "./persistence"; -import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons"; +import { LANGUAGE_MAPPINGS } from "./i18n"; // currently required by excalidraw, in order to allows self-hosting fonts locally. // this avoids making excalidraw load the fonts from an external CDN. window.EXCALIDRAW_ASSET_PATH = `${window.location.pathname}/node_modules/@excalidraw/excalidraw/dist/prod`; -const LANGUAGE_MAPPINGS: Record = { - ar: "ar-SA", - cn: "zh-CN", - de: "de-DE", - en: "en", - en_rtl: "en", - es: "es-ES", - fr: "fr-FR", - it: "it-IT", - ja: "ja-JP", - pt: "pt-PT", - pt_br: "pt-BR", - ro: "ro-RO", - ru: "ru-RU", - tw: "zh-TW", - uk: "uk-UA" -}; - export default function Canvas({ note, noteContext }: TypeWidgetProps) { const apiRef = useRef(null); const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly"); diff --git a/apps/client/src/widgets/type_widgets/canvas/i18n.spec.ts b/apps/client/src/widgets/type_widgets/canvas/i18n.spec.ts new file mode 100644 index 000000000..71eb3d18c --- /dev/null +++ b/apps/client/src/widgets/type_widgets/canvas/i18n.spec.ts @@ -0,0 +1,29 @@ +import { LOCALES } from "@triliumnext/commons"; +import { readdirSync } from "fs"; +import { join } from "path"; +import { describe, expect, it } from "vitest"; +import { LANGUAGE_MAPPINGS } from "./i18n.js"; + +const localeDir = join(__dirname, "../../../../../../node_modules/@excalidraw/excalidraw/dist/prod/locales"); + +describe("Canvas i18n", () => { + it("all languages are mapped correctly", () => { + // Read the node_modules dir to obtain all the supported locales. + const supportedLanguageCodes = new Set(); + for (const file of readdirSync(localeDir)) { + if (file.startsWith("percentages")) continue; + const match = file.match("^[a-z]{2,3}(?:-[A-Z]{2,3})?"); + if (!match) continue; + supportedLanguageCodes.add(match[0]); + } + + // Cross-check the locales. + for (const locale of LOCALES) { + if (locale.contentOnly || locale.devOnly) continue; + const languageCode = LANGUAGE_MAPPINGS[locale.id]; + if (!supportedLanguageCodes.has(languageCode)) { + expect.fail(`Unable to find locale for ${locale.id} -> ${languageCode}.`) + } + } + }); +}); diff --git a/apps/client/src/widgets/type_widgets/canvas/i18n.ts b/apps/client/src/widgets/type_widgets/canvas/i18n.ts new file mode 100644 index 000000000..43ee724cf --- /dev/null +++ b/apps/client/src/widgets/type_widgets/canvas/i18n.ts @@ -0,0 +1,19 @@ +import type { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons"; + +export const LANGUAGE_MAPPINGS: Record = { + ar: "ar-SA", + cn: "zh-CN", + de: "de-DE", + en: "en", + en_rtl: "en", + es: "es-ES", + fr: "fr-FR", + it: "it-IT", + ja: "ja-JP", + pt: "pt-PT", + pt_br: "pt-BR", + ro: "ro-RO", + ru: "ru-RU", + tw: "zh-TW", + uk: "uk-UA" +}; From cc0e30e3f559404c8392df93bfb7ebbf4365b385 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 21:18:34 +0200 Subject: [PATCH 6/8] test(ckeditor): test all languages are mapped correctly --- .../widgets/type_widgets/text/config.spec.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 apps/client/src/widgets/type_widgets/text/config.spec.ts diff --git a/apps/client/src/widgets/type_widgets/text/config.spec.ts b/apps/client/src/widgets/type_widgets/text/config.spec.ts new file mode 100644 index 000000000..5e85bab3b --- /dev/null +++ b/apps/client/src/widgets/type_widgets/text/config.spec.ts @@ -0,0 +1,39 @@ +import { DISPLAYABLE_LOCALE_IDS, LOCALES } from "@triliumnext/commons"; +import { describe, expect, it, vi } from "vitest"; + +vi.mock('../../../services/options.js', () => ({ + default: { + get(name: string) { + if (name === "allowedHtmlTags") return "[]"; + return undefined; + }, + getJson: () => [] + } +})); + +describe("CK config", () => { + it("maps all languages correctly", async () => { + const { buildConfig } = await import("./config.js"); + for (const locale of LOCALES) { + if (locale.contentOnly || locale.devOnly) continue; + + const config = await buildConfig({ + uiLanguage: locale.id as DISPLAYABLE_LOCALE_IDS, + contentLanguage: locale.id, + forceGplLicense: false, + isClassicEditor: false, + templates: [] + }); + + let expectedLocale = locale.id.substring(0, 2); + if (expectedLocale === "cn") expectedLocale = "zh"; + if (expectedLocale === "tw") expectedLocale = "zh-tw"; + + if (locale.id !== "en") { + expect((config.language as any).ui).toMatch(new RegExp(`^${expectedLocale}`)); + expect(config.translations, locale.id).toBeDefined(); + expect(config.translations, locale.id).toHaveLength(2); + } + } + }); +}); From 5281e8e5b4b6f0a434cb0de46b2dc759e06cf637 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 21:24:34 +0200 Subject: [PATCH 7/8] docs(dev): document adding a new locale --- .../User Guide/Advanced Usage/Attributes.html | 24 +- .../Attributes/Promoted Attributes.html | 112 ++- .../User Guide/Collections/Geo Map.html | 654 +++++++++--------- .../User Guide/Collections/Kanban Board.html | 155 ++--- docs/Developer Guide/!!!meta.json | 35 + .../Internationalisation Translat.md | 8 +- .../Adding a new locale.md | 11 + .../Developer Guide/Documentation.md | 2 +- docs/User Guide/!!!meta.json | 184 ++--- 9 files changed, 601 insertions(+), 584 deletions(-) create mode 100644 docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes.html index 3825c8af8..c52770536 100644 --- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes.html +++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Advanced Usage/Attributes.html @@ -5,14 +5,14 @@

In Trilium, attributes are key-value pairs assigned to notes, providing additional metadata or functionality. There are two primary types of attributes:

    -
  1. +
  2. Labels can be used for a variety of purposes, such as storing metadata or configuring the behavior of notes. Labels are also searchable, enhancing note retrieval.

    For more information, including predefined labels, see Labels.

  3. -
  4. +
  5. Relations define connections between notes, similar to links. These can be used for metadata and scripting purposes.

    @@ -27,25 +27,24 @@

    Conceptually there are two types of attributes (applying to both labels and relations):

      -
    1. System attributes +
    2. System attributes
      As the name suggest, these attributes have a special meaning since they are interpreted by Trilium. For example the color attribute will change the color of the note as displayed in the Note Tree and - links, and iconClass will change the icon of a note. -
       
    3. -
    4. User-defined attributes + href="#root/_help_oPVyFC7WL2Lp">Note Tree and links, and iconClass will + change the icon of a note.
    5. +
    6. User-defined attributes
      These are free-form labels or relations that can be used by the user. They can be used purely for categorization purposes (especially if combined - with Search), + with Search), or they can be given meaning through the use of Scripting.
    7. + href="#root/_help_CdNpE2pqjmI6">Scripting.

    In practice, Trilium makes no direct distinction of whether an attribute is a system one or a user-defined one. A label or relation is considered a system attribute if it matches one of the built-in names (e.g. like the aforementioned iconClass). Keep this in mind when creating -  Promoted Attributes in +  Promoted Attributes in order not to accidentally alter a system attribute (unless intended).

    Viewing the list of attributes

    Both the labels and relations for the current note are displayed in the Owned Attributes section @@ -56,14 +55,13 @@

    In the list of attributes, labels are prefixed with the # character whereas relations are prefixed with the ~ character.

    Attribute Definitions and Promoted Attributes

    -

    Promoted Attributes create +

    Promoted Attributes create a form-like editing experience for attributes, which makes it easy to enhancing the organization and management of attributes

    Multiplicity

    Attributes in Trilium can be "multi-valued", meaning multiple attributes with the same name can co-exist. This can be combined with Promoted Attributes to - easily add them.

    + href="#root/_help_OFXdgB2nNk1F">Promoted Attributes to easily add them.

    Attribute Inheritance

    Trilium supports attribute inheritance, allowing child notes to inherit attributes from their parents. For more information, see 

    The Attribute definition specifies how should this value be interpreted:

      -
    • Is it just string, or is it a date?
    • -
    • Should we allow multiple values or note?
    • -
    • Should we promote the attribute or not?
    • +
    • Is it just string, or is it a date?
    • +
    • Should we allow multiple values or note?
    • +
    • Should we promote the attribute or not?

    Creating a new promoted attribute definition

    To create a new promoted attribute:

      -
    1. Go to a note.
    2. -
    3. Go to Owned Attributes in the Ribbon.
    4. -
    5. Press the + button.
    6. -
    7. Select either Add new label definition or Add new relation definition.
    8. -
    9. Select the name which will be name of the label or relation that will - be created when the promoted attribute is edited.
    10. -
    11. Ensure Promoted is checked in order to display it at the top of - notes.
    12. -
    13. Optionally, choose an Alias which will be displayed next to the - promoted attribute instead of the attribute name. Generally it's best to - choose a “user-friendly” name since it can contain spaces and other characters - which are not supported as attribute names.
    14. -
    15. Check Inheritable to apply it to this note and all its descendants. - To keep it only for the current note, un-check it.
    16. -
    17. Press “Save & Close” to apply the changes.
    18. +
    19. Go to a note.
    20. +
    21. Go to Owned Attributes in the Ribbon.
    22. +
    23. Press the + button.
    24. +
    25. Select either Add new label definition or Add new relation definition.
    26. +
    27. Select the name which will be name of the label or relation that will + be created when the promoted attribute is edited.
    28. +
    29. Ensure Promoted is checked in order to display it at the top of + notes.
    30. +
    31. Optionally, choose an Alias which will be displayed next to the + promoted attribute instead of the attribute name. Generally it's best to + choose a “user-friendly” name since it can contain spaces and other characters + which are not supported as attribute names.
    32. +
    33. Check Inheritable to apply it to this note and all its descendants. + To keep it only for the current note, un-check it.
    34. +
    35. Press “Save & Close” to apply the changes.

    How attribute definitions actually work

    When a new promoted attribute definition is created, it creates a corresponding @@ -54,37 +52,37 @@

    The only purpose of the attribute definition is to set up a template. If the attribute was marked as promoted, then it's also displayed to the user for easy editing.

    -
    - - - - - - - - - - - - - - - -
    -
    - -
    -
    Notice how the promoted attribute definition only creates a “Due date” - box above the text content.
    -
    - -
    -
    Once a value is set by the user, a new label (or relation, depending on - the type) is created. The name of the attribute matches one set when creating - the promoted attribute.
    -
    + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    Notice how the promoted attribute definition only creates a “Due date” + box above the text content.
    +
    + +
    +
    Once a value is set by the user, a new label (or relation, depending on + the type) is created. The name of the attribute matches one set when creating + the promoted attribute.

    So there's one attribute for value and one for definition. But notice how an definition attribute can be made Inheritable, meaning that it's also applied to all descendant notes. In this case, the @@ -95,22 +93,22 @@ to be able to easily alter them.

    Here are a few practical examples:

      -
    • Collections already +
    • Collections already make use of this practice, for example:
        -
      • Calendars add “Start Date”, “End Date”, “Start Time” and “End Time” as +
      • Calendars add “Start Date”, “End Date”, “Start Time” and “End Time” as promoted attributes. These map to system attributes such as startDate which are then interpreted by the calendar view.
      • -
      • Presentation adds +
      • Presentation adds a “Background” promoted attribute for each of the slide to easily be able to customize.
    • -
    • The Trilium documentation (which is edited in Trilium) uses a promoted +
    • The Trilium documentation (which is edited in Trilium) uses a promoted attribute to be able to easily edit the #shareAlias (see  Sharing) in order to form clean URLs.
    • -
    • If you always edit a particular system attribute such as #color, + class="reference-link" href="#root/_help_R9pX4DGra2Vt">Sharing) in order to form clean URLs.
    • +
    • If you always edit a particular system attribute such as #color, simply create a promoted attribute for it to make it easier.

    Inverse relation

    diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html index 58f9014d1..e7e3c73f6 100644 --- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html +++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html @@ -1,11 +1,9 @@

    Creating a new geo map

    -
    - - - - - - - - - - - - - - - - - - - - -
       
    1 -
    - -
    -
    Right click on any note on the note tree and select Insert child noteGeo Map (beta).
    2 -
    - -
    -
    By default the map will be empty and will show the entire world.
    -
    + + + + + + + + + + + + + + + + + + + + +
    1 +
    + +
    +
    Right click on any note on the note tree and select Insert child noteGeo Map (beta).
    2 +
    + +
    +
    By default the map will be empty and will show the entire world.
    +

    Repositioning the map

      -
    • Click and drag the map in order to move across the map.
    • -
    • Use the mouse wheel, two-finger gesture on a touchpad or the +/- buttons +
    • Click and drag the map in order to move across the map.
    • +
    • Use the mouse wheel, two-finger gesture on a touchpad or the +/- buttons on the top-left to adjust the zoom.

    The position on the map and the zoom are saved inside the map note and restored when visiting again the note.

    Adding a marker using the map

    Adding a new note using the plus button

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
    1To create a marker, first navigate to the desired point on the map. Then - press the - button in the Floating buttons (top-right) - area.     -
    -
    If the button is not visible, make sure the button section is visible - by pressing the chevron button ( - ) in the top-right of the map.
     
    2 - - Once pressed, the map will enter in the insert mode, as illustrated by - the notification.        -
    -
    Simply click the point on the map where to place the marker, or the Escape - key to cancel.
    3 - - Enter the name of the marker/note to be created.
    4 - - Once confirmed, the marker will show up on the map and it will also be - displayed as a child note of the map.
    -
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    1To create a marker, first navigate to the desired point on the map. Then + press the + button in the Floating buttons (top-right) + area.     +
    +
    If the button is not visible, make sure the button section is visible + by pressing the chevron button ( + ) in the top-right of the map.
    2 + + Once pressed, the map will enter in the insert mode, as illustrated by + the notification.        +
    +
    Simply click the point on the map where to place the marker, or the Escape + key to cancel.
    3 + + Enter the name of the marker/note to be created.
    4 + + Once confirmed, the marker will show up on the map and it will also be + displayed as a child note of the map.
    +

    Adding a new note using the contextual menu

      -
    1. Right click anywhere on the map, where to place the newly created marker +
    2. Right click anywhere on the map, where to place the newly created marker (and corresponding note).
    3. -
    4. Select Add a marker at this location.
    5. -
    6. Enter the name of the neNote Treewly +
    7. Select Add a marker at this location.
    8. +
    9. Enter the name of the neNote Treewly created note.
    10. -
    11. The map should be updated with the new marker.
    12. +
    13. The map should be updated with the new marker.

    Adding an existing note on note from the note tree

      -
    1. Select the desired note in the Note Tree.
    2. -
    3. Hold the mouse on the note and drag it to the map to the desired location.
    4. -
    5. The map should be updated with the new marker.
    6. +
    7. Select the desired note in the Note Tree.
    8. +
    9. Hold the mouse on the note and drag it to the map to the desired location.
    10. +
    11. The map should be updated with the new marker.

    This works for:

      -
    • Notes that are not part of the geo map, case in which a clone will +
    • Notes that are not part of the geo map, case in which a clone will be created.
    • -
    • Notes that are a child of the geo map but not yet positioned on the map.
    • -
    • Notes that are a child of the geo map and also positioned, case in which +
    • Notes that are a child of the geo map but not yet positioned on the map.
    • +
    • Notes that are a child of the geo map and also positioned, case in which the marker will be relocated to the new position.
    -

    A more advanced use-case is grouping by Relations.

    +

    A more advanced use-case is grouping by Relations.

    During this mode:

      -
    • The columns represent the target notes of a relation.
    • -
    • When creating a new column, a note is selected instead of a column name.
    • -
    • The column icon will match the target note.
    • -
    • Moving notes between columns will change its relation.
    • -
    • Renaming an existing column will change the target note of all the notes - in that column.
    • +
    • The columns represent the target notes of a relation.
    • +
    • When creating a new column, a note is selected instead of a column name.
    • +
    • The column icon will match the target note.
    • +
    • Moving notes between columns will change its relation.
    • +
    • Renaming an existing column will change the target note of all the notes + in that column.

    Using relations instead of labels has some benefits:

      -
    • The status/grouping of the notes is visible outside the Kanban board, - for example on the Note Map.
    • -
    • Columns can have icons.
    • -
    • Renaming columns is less intensive since it simply involves changing the - note title of the target note instead of having to do a bulk rename.
    • +
    • The status/grouping of the notes is visible outside the Kanban board, + for example on the Note Map.
    • +
    • Columns can have icons.
    • +
    • Renaming columns is less intensive since it simply involves changing the + note title of the target note instead of having to do a bulk rename.

    To do so:

      -
    1. First, create a Kanban board from scratch and not a template:
    2. -
    3. Assign #viewType=board #hidePromotedAttributes to emulate the - default template.
    4. -
    5. Set #board:groupBy to the name of a relation to group by, including the ~ prefix (e.g. ~status).
    6. -
    7. -

      Optionally, use Promoted Attributes for - easy status change within the note:

      #relation:status(inheritable)="promoted,alias=Status,single"
      -
    8. +
    9. +

      First, create a Kanban board from scratch and not a template:

      +
    10. +
    11. +

      Assign #viewType=board #hidePromotedAttributes to emulate the + default template.

      +
    12. +
    13. +

      Set #board:groupBy to the name of a relation to group by, including the **~** prefix (e.g. ~status).

      +
    14. +
    15. +

      Optionally, use Promoted Attributes for + easy status change within the note:

      #relation:status(inheritable)="promoted,alias=Status,single"
      +
    \ No newline at end of file diff --git a/docs/Developer Guide/!!!meta.json b/docs/Developer Guide/!!!meta.json index cdf47264f..9e479b0cc 100644 --- a/docs/Developer Guide/!!!meta.json +++ b/docs/Developer Guide/!!!meta.json @@ -1974,6 +1974,13 @@ "value": "i18n", "isInheritable": false, "position": 20 + }, + { + "type": "relation", + "name": "internalLink", + "value": "lXjOyKpUSKgE", + "isInheritable": false, + "position": 30 } ], "format": "markdown", @@ -2071,6 +2078,34 @@ "format": "markdown", "dataFileName": "Server translations.md", "attachments": [] + }, + { + "isClone": false, + "noteId": "lXjOyKpUSKgE", + "notePath": [ + "jdjRLhLV3TtI", + "yeqU0zo0ZQ83", + "TLXJwBDo8Rdv", + "lXjOyKpUSKgE" + ], + "title": "Adding a new locale", + "notePosition": 40, + "prefix": null, + "isExpanded": false, + "type": "text", + "mime": "text/html", + "attributes": [ + { + "type": "label", + "name": "shareAlias", + "value": "new-locale", + "isInheritable": false, + "position": 20 + } + ], + "format": "markdown", + "dataFileName": "Adding a new locale.md", + "attachments": [] } ] }, diff --git a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md index 7ae59016f..2449b6c72 100644 --- a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md +++ b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md @@ -15,7 +15,7 @@ One important aspect is the fact that we are using a key-based approach. This me The key-based approach allows a hierarchical structure. For example, a key of `about.title` would be added in `translation.json` as follows: -```json +``` { "about": { "title": "About Trilium Notes" @@ -27,11 +27,7 @@ Follow the Adding a new locale. ### Changing the language diff --git a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md new file mode 100644 index 000000000..e36815b90 --- /dev/null +++ b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translations/Adding a new locale.md @@ -0,0 +1,11 @@ +# Adding a new locale +Once the Weblate translations for a single language have reached ~50% in coverage, it's time to add it to the application. + +To do so: + +1. In `packages/commons` look for `i18n.ts` and add a new entry to `UNSORTED_LOCALES` for the language. +2. In `apps/server` look for `services/i18n.ts` and add a mapping for the new language in `DAYJS_LOADER`. Sort the entire list. +3. In `apps/client`, look for `collections/calendar/index.tsx` and modify `LOCALE_MAPPINGS` to add support to the new language. +4. In `apps/client`, look for `widgets/type_widgets/canvas/i18n.ts` and modify `LANGUAGE_MAPPINGS`. A unit test ensures that the language is actually loadable. +5. In `apps/client`, look for `widgets/type_widgets/MindMap.tsx` and modify `LOCALE_MAPPINGS`. The type definitions should already validate if the new value is supported by Mind Elixir. +6. In `packages/ckeditor5`, look for `i18n.ts` and modify `LOCALE_MAPPINGS`. The import validation should already check if the new value is supported by CKEditor, and there's also a test to ensure it. \ No newline at end of file diff --git a/docs/Developer Guide/Developer Guide/Documentation.md b/docs/Developer Guide/Developer Guide/Documentation.md index 5f9f17e5f..617684bfd 100644 --- a/docs/Developer Guide/Developer Guide/Documentation.md +++ b/docs/Developer Guide/Developer Guide/Documentation.md @@ -1,5 +1,5 @@ # Documentation -There are multiple types of documentation for Trilium: +There are multiple types of documentation for Trilium: * The _User Guide_ represents the user-facing documentation. This documentation can be browsed by users directly from within Trilium, by pressing F1. * The _Developer's Guide_ represents a set of Markdown documents that present the internals of Trilium, for developers. diff --git a/docs/User Guide/!!!meta.json b/docs/User Guide/!!!meta.json index f859cd689..40a40e9fc 100644 --- a/docs/User Guide/!!!meta.json +++ b/docs/User Guide/!!!meta.json @@ -9872,23 +9872,16 @@ "position": 10 }, { - "type": "label", - "name": "iconClass", - "value": "bx bx-columns", - "isInheritable": false, - "position": 10 - }, - { - "type": "label", - "name": "shareAlias", - "value": "kanban-board", + "type": "relation", + "name": "internalLink", + "value": "oPVyFC7WL2Lp", "isInheritable": false, "position": 20 }, { "type": "relation", "name": "internalLink", - "value": "Cq5X6iKQop6R", + "value": "IakOLONlIfGI", "isInheritable": false, "position": 30 }, @@ -9902,23 +9895,30 @@ { "type": "relation", "name": "internalLink", - "value": "bdUJEHsAPYQR", + "value": "Cq5X6iKQop6R", "isInheritable": false, "position": 50 }, { "type": "relation", "name": "internalLink", - "value": "oPVyFC7WL2Lp", + "value": "bdUJEHsAPYQR", "isInheritable": false, "position": 60 }, { - "type": "relation", - "name": "internalLink", - "value": "IakOLONlIfGI", + "type": "label", + "name": "iconClass", + "value": "bx bx-columns", "isInheritable": false, - "position": 70 + "position": 10 + }, + { + "type": "label", + "name": "shareAlias", + "value": "kanban-board", + "isInheritable": false, + "position": 20 } ], "format": "markdown", @@ -9968,59 +9968,73 @@ { "type": "relation", "name": "internalLink", - "value": "KSZ04uQ2D1St", + "value": "zEY4DaJG4YT5", "isInheritable": false, "position": 10 }, { "type": "relation", "name": "internalLink", - "value": "0ESUbbAxVnoK", + "value": "OFXdgB2nNk1F", "isInheritable": false, "position": 20 }, { "type": "relation", "name": "internalLink", - "value": "XpOYSgsLkTJy", + "value": "KSZ04uQ2D1St", "isInheritable": false, "position": 30 }, { "type": "relation", "name": "internalLink", - "value": "oPVyFC7WL2Lp", + "value": "0ESUbbAxVnoK", "isInheritable": false, "position": 40 }, { "type": "relation", "name": "internalLink", - "value": "IakOLONlIfGI", + "value": "XpOYSgsLkTJy", "isInheritable": false, "position": 50 }, { "type": "relation", "name": "internalLink", - "value": "lgKX7r3aL30x", + "value": "oPVyFC7WL2Lp", "isInheritable": false, "position": 60 }, { "type": "relation", "name": "internalLink", - "value": "ZjLYv08Rp3qC", + "value": "IakOLONlIfGI", "isInheritable": false, "position": 70 }, { "type": "relation", "name": "internalLink", - "value": "BlN9DFI679QC", + "value": "lgKX7r3aL30x", "isInheritable": false, "position": 80 }, + { + "type": "relation", + "name": "internalLink", + "value": "ZjLYv08Rp3qC", + "isInheritable": false, + "position": 90 + }, + { + "type": "relation", + "name": "internalLink", + "value": "BlN9DFI679QC", + "isInheritable": false, + "position": 100 + }, { "type": "label", "name": "iconClass", @@ -10034,20 +10048,6 @@ "value": "geomap", "isInheritable": false, "position": 90 - }, - { - "type": "relation", - "name": "internalLink", - "value": "zEY4DaJG4YT5", - "isInheritable": false, - "position": 100 - }, - { - "type": "relation", - "name": "internalLink", - "value": "OFXdgB2nNk1F", - "isInheritable": false, - "position": 110 } ], "format": "markdown", @@ -11240,24 +11240,45 @@ { "type": "relation", "name": "internalLink", - "value": "BlN9DFI679QC", + "value": "oPVyFC7WL2Lp", "isInheritable": false, "position": 30 }, { "type": "relation", "name": "internalLink", - "value": "OFXdgB2nNk1F", + "value": "eIg8jdvaoNNd", "isInheritable": false, "position": 40 }, { "type": "relation", "name": "internalLink", - "value": "bwZpz2ajCEwO", + "value": "CdNpE2pqjmI6", "isInheritable": false, "position": 50 }, + { + "type": "relation", + "name": "internalLink", + "value": "OFXdgB2nNk1F", + "isInheritable": false, + "position": 60 + }, + { + "type": "relation", + "name": "internalLink", + "value": "BlN9DFI679QC", + "isInheritable": false, + "position": 70 + }, + { + "type": "relation", + "name": "internalLink", + "value": "bwZpz2ajCEwO", + "isInheritable": false, + "position": 80 + }, { "type": "label", "name": "shareAlias", @@ -11271,27 +11292,6 @@ "value": "bx bx-list-check", "isInheritable": false, "position": 110 - }, - { - "type": "relation", - "name": "internalLink", - "value": "oPVyFC7WL2Lp", - "isInheritable": false, - "position": 120 - }, - { - "type": "relation", - "name": "internalLink", - "value": "eIg8jdvaoNNd", - "isInheritable": false, - "position": 130 - }, - { - "type": "relation", - "name": "internalLink", - "value": "CdNpE2pqjmI6", - "isInheritable": false, - "position": 140 } ], "format": "markdown", @@ -11740,10 +11740,38 @@ { "type": "relation", "name": "internalLink", - "value": "bwZpz2ajCEwO", + "value": "BlN9DFI679QC", "isInheritable": false, "position": 20 }, + { + "type": "relation", + "name": "internalLink", + "value": "bwZpz2ajCEwO", + "isInheritable": false, + "position": 30 + }, + { + "type": "relation", + "name": "internalLink", + "value": "GTwFsgaA0lCt", + "isInheritable": false, + "position": 40 + }, + { + "type": "relation", + "name": "internalLink", + "value": "zP3PMqaG71Ct", + "isInheritable": false, + "position": 50 + }, + { + "type": "relation", + "name": "internalLink", + "value": "R9pX4DGra2Vt", + "isInheritable": false, + "position": 60 + }, { "type": "label", "name": "shareAlias", @@ -11757,34 +11785,6 @@ "value": "bx bx-table", "isInheritable": false, "position": 20 - }, - { - "type": "relation", - "name": "internalLink", - "value": "BlN9DFI679QC", - "isInheritable": false, - "position": 50 - }, - { - "type": "relation", - "name": "internalLink", - "value": "GTwFsgaA0lCt", - "isInheritable": false, - "position": 60 - }, - { - "type": "relation", - "name": "internalLink", - "value": "zP3PMqaG71Ct", - "isInheritable": false, - "position": 70 - }, - { - "type": "relation", - "name": "internalLink", - "value": "R9pX4DGra2Vt", - "isInheritable": false, - "position": 80 } ], "format": "markdown", From 17298edfcc316ce31bd158f993ca09b47d954147 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Nov 2025 21:32:08 +0200 Subject: [PATCH 8/8] chore: handle requested changes --- apps/client/src/widgets/type_widgets/MindMap.tsx | 2 +- apps/client/src/widgets/type_widgets/canvas/Canvas.tsx | 3 ++- .../Developer Guide/Concepts/Internationalisation Translat.md | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/MindMap.tsx b/apps/client/src/widgets/type_widgets/MindMap.tsx index 715612947..b4ccdf371 100644 --- a/apps/client/src/widgets/type_widgets/MindMap.tsx +++ b/apps/client/src/widgets/type_widgets/MindMap.tsx @@ -136,7 +136,7 @@ function MindElixir({ containerRef: externalContainerRef, containerProps, apiRef const mind = new VanillaMindElixir({ el: containerRef.current, - locale: LOCALE_MAPPINGS[locale], + locale: LOCALE_MAPPINGS[locale as DISPLAYABLE_LOCALE_IDS] ?? undefined, editable }); diff --git a/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx b/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx index fb5cc1df5..6a5ea9377 100644 --- a/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx +++ b/apps/client/src/widgets/type_widgets/canvas/Canvas.tsx @@ -10,6 +10,7 @@ import { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/type import { goToLinkExt } from "../../../services/link"; import useCanvasPersistence from "./persistence"; import { LANGUAGE_MAPPINGS } from "./i18n"; +import { DISPLAYABLE_LOCALE_IDS } from "@triliumnext/commons"; // currently required by excalidraw, in order to allows self-hosting fonts locally. // this avoids making excalidraw load the fonts from an external CDN. @@ -60,7 +61,7 @@ export default function Canvas({ note, noteContext }: TypeWidgetProps) { detectScroll={false} handleKeyboardGlobally={false} autoFocus={false} - langCode={LANGUAGE_MAPPINGS[locale]} + langCode={LANGUAGE_MAPPINGS[locale as DISPLAYABLE_LOCALE_IDS] ?? undefined} UIOptions={{ canvasActions: { saveToActiveFile: false, diff --git a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md index 2449b6c72..f420ff7ad 100644 --- a/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md +++ b/docs/Developer Guide/Developer Guide/Concepts/Internationalisation Translat.md @@ -15,7 +15,7 @@ One important aspect is the fact that we are using a key-based approach. This me The key-based approach allows a hierarchical structure. For example, a key of `about.title` would be added in `translation.json` as follows: -``` +```json { "about": { "title": "About Trilium Notes"