mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
Merge branch 'main' into patch_import_markdown
This commit is contained in:
@@ -56,7 +56,20 @@ function SingleNoteRenderer({ note, onReady }: RendererProps) {
|
||||
await import("@triliumnext/ckeditor5/src/theme/ck-content.css");
|
||||
}
|
||||
const { $renderedContent } = await content_renderer.getRenderedContent(note, { noChildrenList: true });
|
||||
containerRef.current?.replaceChildren(...$renderedContent);
|
||||
const container = containerRef.current!;
|
||||
container.replaceChildren(...$renderedContent);
|
||||
|
||||
// Wait for all images to load.
|
||||
const images = Array.from(container.querySelectorAll("img"));
|
||||
await Promise.all(
|
||||
images.map(img => {
|
||||
if (img.complete) return Promise.resolve();
|
||||
return new Promise<void>(resolve => {
|
||||
img.addEventListener("load", () => resolve(), { once: true });
|
||||
img.addEventListener("error", () => resolve(), { once: true });
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
load().then(() => requestAnimationFrame(onReady))
|
||||
|
||||
@@ -1658,7 +1658,7 @@
|
||||
"add-term-to-dictionary": "Begriff \"{{term}}\" zum Wörterbuch hinzufügen",
|
||||
"cut": "Ausschneiden",
|
||||
"copy": "Kopieren",
|
||||
"copy-link": "Link opieren",
|
||||
"copy-link": "Link kopieren",
|
||||
"paste": "Einfügen",
|
||||
"paste-as-plain-text": "Als unformatierten Text einfügen",
|
||||
"search_online": "Suche nach \"{{term}}\" mit {{searchEngine}} starten"
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
"critical-error": {
|
||||
"title": "Kritische Error",
|
||||
"message": "Een kritieke fout heeft plaatsgevonden waardoor de cliënt zich aanmeldt vanaf het begin:\n\n84X\n\nDit is waarschijnlijk veroorzaakt door een script dat op een onverwachte manier faalt. Probeer de sollicitatie in veilige modus te starten en de kwestie aan te spreken."
|
||||
},
|
||||
"widget-error": {
|
||||
"title": "Starten widget mislukt",
|
||||
"message-unknown": "Onbekende widget kan niet gestart worden omdat:\n\n{{message}}"
|
||||
},
|
||||
"bundle-error": {
|
||||
"title": "Custom script laden mislukt"
|
||||
}
|
||||
},
|
||||
"add_link": {
|
||||
|
||||
@@ -155,6 +155,11 @@ export default class PopupEditorDialog extends Container<BasicWidget> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// Avoid not showing recent notes when creating a new empty tab.
|
||||
if ("noteContext" in data && data.noteContext.ntxId !== "_popup-editor") {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return super.handleEventInChildren(name, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ WHERE powershell.exe > NUL 2>&1
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO BATCH ELSE GOTO POWERSHELL
|
||||
|
||||
:POWERSHELL
|
||||
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo "Set-Item -Path Env:NODE_TLS_REJECT_UNAUTHORIZED -Value 0; ./trilium.exe"
|
||||
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command "Set-Item -Path Env:NODE_TLS_REJECT_UNAUTHORIZED -Value 0; ./trilium.exe"
|
||||
GOTO END
|
||||
|
||||
:BATCH
|
||||
|
||||
@@ -6,7 +6,7 @@ WHERE powershell.exe > NUL 2>&1
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO BATCH ELSE GOTO POWERSHELL
|
||||
|
||||
:POWERSHELL
|
||||
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo "Set-Item -Path Env:TRILIUM_DATA_DIR -Value './trilium-data'; ./trilium.exe"
|
||||
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command "Set-Item -Path Env:TRILIUM_DATA_DIR -Value './trilium-data'; ./trilium.exe"
|
||||
GOTO END
|
||||
|
||||
:BATCH
|
||||
|
||||
@@ -6,7 +6,7 @@ WHERE powershell.exe > NUL 2>&1
|
||||
IF %ERRORLEVEL% NEQ 0 GOTO BATCH ELSE GOTO POWERSHELL
|
||||
|
||||
:POWERSHELL
|
||||
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo "Set-Item -Path Env:TRILIUM_SAFE_MODE -Value 1; ./trilium.exe --disable-gpu"
|
||||
powershell -ExecutionPolicy Bypass -NonInteractive -NoLogo -Command "Set-Item -Path Env:TRILIUM_SAFE_MODE -Value 1; ./trilium.exe --disable-gpu"
|
||||
GOTO END
|
||||
|
||||
:BATCH
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/src/assets/favicon.ico" />
|
||||
|
||||
@@ -19,6 +19,7 @@ describe("swapLocale", () => {
|
||||
expect(swapLocaleInUrl("/ro/get-started", "ro")).toStrictEqual("/ro/get-started");
|
||||
expect(swapLocaleInUrl("/en/get-started", "ro")).toStrictEqual("/ro/get-started");
|
||||
expect(swapLocaleInUrl("/ro/", "en")).toStrictEqual("/en/");
|
||||
expect(swapLocaleInUrl("/ro", "en")).toStrictEqual("/en");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,36 @@
|
||||
import i18next from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
interface Locale {
|
||||
id: string;
|
||||
name: string;
|
||||
rtl?: boolean;
|
||||
}
|
||||
|
||||
i18next.use(initReactI18next);
|
||||
const localeFiles = import.meta.glob("./translations/*/translation.json", { eager: true });
|
||||
const resources: Record<string, Record<string, Record<string, string>>> = {};
|
||||
for (const [path, module] of Object.entries(localeFiles)) {
|
||||
const id = path.split("/").at(-2);
|
||||
if (!id) continue;
|
||||
|
||||
const translations = (module as any).default ?? module;
|
||||
resources[id] = { translation: translations };
|
||||
}
|
||||
|
||||
export function initTranslations(lng: string) {
|
||||
i18next.init({
|
||||
fallbackLng: "en",
|
||||
lng,
|
||||
returnEmptyString: false,
|
||||
resources,
|
||||
initAsync: false,
|
||||
react: {
|
||||
useSuspense: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const LOCALES: Locale[] = [
|
||||
{ id: "en", name: "English" },
|
||||
{ id: "ro", name: "Română" },
|
||||
@@ -35,7 +62,13 @@ export function mapLocale(locale: string) {
|
||||
export function swapLocaleInUrl(url: string, newLocale: string) {
|
||||
const components = url.split("/");
|
||||
if (components.length === 2) {
|
||||
return `/${newLocale}${url}`;
|
||||
const potentialLocale = components[1];
|
||||
const correspondingLocale = LOCALES.find(l => l.id === potentialLocale);
|
||||
if (correspondingLocale) {
|
||||
return `/${newLocale}`;
|
||||
} else {
|
||||
return `/${newLocale}${url}`;
|
||||
}
|
||||
} else {
|
||||
components[1] = newLocale;
|
||||
return components.join("/");
|
||||
|
||||
@@ -8,11 +8,9 @@ import Footer from './components/Footer.js';
|
||||
import GetStarted from './pages/GetStarted/get-started.js';
|
||||
import SupportUs from './pages/SupportUs/SupportUs.js';
|
||||
import { createContext } from 'preact';
|
||||
import { useLayoutEffect, useState } from 'preact/hooks';
|
||||
import { default as i18next, changeLanguage } from 'i18next';
|
||||
import { extractLocaleFromUrl, LOCALES, mapLocale } from './i18n';
|
||||
import HttpApi from 'i18next-http-backend';
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import { useLayoutEffect, useRef } from 'preact/hooks';
|
||||
import { changeLanguage } from 'i18next';
|
||||
import { extractLocaleFromUrl, initTranslations, LOCALES, mapLocale } from './i18n';
|
||||
|
||||
export const LocaleContext = createContext('en');
|
||||
|
||||
@@ -42,34 +40,26 @@ export function App(props: {repoStargazersCount: number}) {
|
||||
|
||||
export function LocaleProvider({ children }) {
|
||||
const { path } = useLocation();
|
||||
const localeId = mapLocale(extractLocaleFromUrl(path) || navigator.language);
|
||||
const [ loaded, setLoaded ] = useState(false);
|
||||
const localeId = getLocaleId(path);
|
||||
const loadedRef = useRef(false);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
i18next
|
||||
.use(HttpApi)
|
||||
.use(initReactI18next);
|
||||
i18next.init({
|
||||
lng: localeId,
|
||||
fallbackLng: "en",
|
||||
backend: {
|
||||
loadPath: "/translations/{{lng}}/{{ns}}.json",
|
||||
},
|
||||
returnEmptyString: false
|
||||
}).then(() => setLoaded(true))
|
||||
}, []);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!loaded) return;
|
||||
if (!loadedRef.current) {
|
||||
initTranslations(localeId);
|
||||
loadedRef.current = true;
|
||||
} else {
|
||||
changeLanguage(localeId);
|
||||
}
|
||||
|
||||
// Update html lang and dir attributes
|
||||
useLayoutEffect(() => {
|
||||
const correspondingLocale = LOCALES.find(l => l.id === localeId);
|
||||
document.documentElement.lang = localeId;
|
||||
document.documentElement.dir = correspondingLocale?.rtl ? "rtl" : "ltr";
|
||||
}, [ loaded, localeId ]);
|
||||
}, [localeId]);
|
||||
|
||||
return (
|
||||
<LocaleContext.Provider value={localeId}>
|
||||
{loaded && children}
|
||||
{children}
|
||||
</LocaleContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -78,12 +68,26 @@ if (typeof window !== 'undefined') {
|
||||
hydrate(<App repoStargazersCount={FALLBACK_STARGAZERS_COUNT} />, document.getElementById('app')!);
|
||||
}
|
||||
|
||||
function getLocaleId(path: string) {
|
||||
const extractedLocale = extractLocaleFromUrl(path);
|
||||
if (extractedLocale) return mapLocale(extractedLocale);
|
||||
if (typeof window === "undefined") return 'en';
|
||||
return mapLocale(navigator.language);
|
||||
}
|
||||
|
||||
export async function prerender(data) {
|
||||
// Fetch the stargazer count of the Trilium's GitHub repo on prerender to pass
|
||||
// it to the App component for SSR.
|
||||
// This ensures the GitHub API is not called on every page load in the client.
|
||||
const stargazersCount = await getRepoStargazersCount();
|
||||
|
||||
return await ssr(<App repoStargazersCount={stargazersCount} {...data} />);
|
||||
const { html, links } = await ssr(<App repoStargazersCount={stargazersCount} {...data} />);
|
||||
return {
|
||||
html,
|
||||
links,
|
||||
head: {
|
||||
lang: extractLocaleFromUrl(data.url) ?? "en"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,7 @@
|
||||
"get_started": "Comenzar"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "Saber más…",
|
||||
"list_with_screenshot_alt": "Captura de pantalla de la función seleccionada"
|
||||
"link_learn_more": "Saber más…"
|
||||
},
|
||||
"download_now": {
|
||||
"text": "Descarga ahora ",
|
||||
@@ -74,8 +74,7 @@
|
||||
"get_started": "Commencer"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "En savoir plus...",
|
||||
"list_with_screenshot_alt": "Capture d'écran de la fonctionnalité sélectionnée"
|
||||
"link_learn_more": "En savoir plus..."
|
||||
},
|
||||
"support_us": {
|
||||
"financial_donations_title": "Dons financiers",
|
||||
@@ -51,7 +51,8 @@
|
||||
"mermaid_description": "Crea diagrammi come diagrammi di flusso, diagrammi di classe e sequenza, diagrammi di Gantt e molti altri, utilizzando la sintassi Mermaid.",
|
||||
"mindmap_title": "Mappe mentali",
|
||||
"mindmap_description": "Organizza i tuoi pensieri visivamente o fai una sessione di brainstorming.",
|
||||
"others_list": "e altri: <0>mappa delle note</0>, <1>mappa delle relazioni</1>, <2>ricerche salvate</2>, <3>renderizza nota</3> e <4>visualizzazioni web</4>."
|
||||
"others_list": "e altri: <0>mappa delle note</0>, <1>mappa delle relazioni</1>, <2>ricerche salvate</2>, <3>renderizza nota</3> e <4>visualizzazioni web</4>.",
|
||||
"title": "Diversi modi per rappresentare le tue informazioni"
|
||||
},
|
||||
"extensibility_benefits": {
|
||||
"title": "Condivisione ed estensibilità",
|
||||
@@ -72,7 +73,10 @@
|
||||
"board_title": "Board",
|
||||
"board_description": "Organizza le tue attività o lo stato dei tuoi progetti in una lavagna Kanban con un modo semplice per creare nuovi elementi e colonne e modificare facilmente il loro stato trascinandoli sulla lavagna.",
|
||||
"geomap_title": "Geomappa",
|
||||
"geomap_description": "Pianifica le tue vacanze o segna i tuoi punti di interesse direttamente su una mappa geografica utilizzando indicatori personalizzabili. Visualizza le tracce GPX registrate per seguire gli itinerari."
|
||||
"geomap_description": "Pianifica le tue vacanze o segna i tuoi punti di interesse direttamente su una mappa geografica utilizzando indicatori personalizzabili. Visualizza le tracce GPX registrate per seguire gli itinerari.",
|
||||
"title": "Collezioni",
|
||||
"presentation_title": "Presentazione",
|
||||
"presentation_description": "Organizza le informazioni in diapositive e presentale a schermo intero con transizioni fluide. Le diapositive possono anche essere esportate in formato PDF per una facile condivisione."
|
||||
},
|
||||
"faq": {
|
||||
"title": "Domande frequenti",
|
||||
@@ -95,8 +99,7 @@
|
||||
"get_started": "Inizia ora"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "Per saperne di più...",
|
||||
"list_with_screenshot_alt": "Screenshot della funzione selezionata"
|
||||
"link_learn_more": "Per saperne di più..."
|
||||
},
|
||||
"download_now": {
|
||||
"text": "Scarica ora ",
|
||||
@@ -188,5 +191,10 @@
|
||||
"description": "Trilium Notes è ospitato su PikaPods, un servizio a pagamento che consente un facile accesso e una semplice gestione. Non è direttamente affiliato al team Trilium.",
|
||||
"download_pikapod": "Configurazione su PikaPods",
|
||||
"download_triliumcc": "In alternativa, consultare trilium.cc"
|
||||
},
|
||||
"header": {
|
||||
"get-started": "Inizia",
|
||||
"documentation": "Documentazione",
|
||||
"support-us": "Sostienici"
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,8 @@
|
||||
"mermaid_description": "Mermaid 構文を使用して、フローチャート、クラス図、シーケンス図、ガント チャートなどの図を作成します。",
|
||||
"mindmap_title": "マインドマップ",
|
||||
"mindmap_description": "考えを視覚的に整理したり、ブレインストーミング セッションを行ったりします。",
|
||||
"others_list": "その他: <0>ノートマップ</0>、<1>リレーションマップ</1>、<2>保存された検索</2>、<3>レンダリングノート</3>、<4>Web ビュー</4>。"
|
||||
"others_list": "その他: <0>ノートマップ</0>、<1>リレーションマップ</1>、<2>保存された検索</2>、<3>レンダリングノート</3>、<4>Web ビュー</4>。",
|
||||
"title": "情報を表現するための複数の方法"
|
||||
},
|
||||
"extensibility_benefits": {
|
||||
"title": "共有と拡張性",
|
||||
@@ -72,7 +73,10 @@
|
||||
"board_title": "ボード",
|
||||
"board_description": "新しい項目や列を簡単に作成し、ボード上でドラッグするだけでステータスを変更できるカンバン ボードで、タスクやプロジェクトのステータスを整理できます。",
|
||||
"geomap_title": "ジオマップ",
|
||||
"geomap_description": "カスタマイズ可能なマーカーを使って、休暇を計画したり、興味のある場所を地図上に直接マークしたりできます。記録されたGPXトラックを表示して、旅程を追跡できます。"
|
||||
"geomap_description": "カスタマイズ可能なマーカーを使って、休暇を計画したり、興味のある場所を地図上に直接マークしたりできます。記録されたGPXトラックを表示して、旅程を追跡できます。",
|
||||
"title": "コレクション",
|
||||
"presentation_title": "プレゼンテーション",
|
||||
"presentation_description": "情報をスライドに整理し、スムーズな遷移で全画面表示できます。スライドはPDFにエクスポートできるので、簡単に共有できます。"
|
||||
},
|
||||
"faq": {
|
||||
"title": "よくある質問",
|
||||
@@ -95,8 +99,7 @@
|
||||
"get_started": "はじめる"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "さらに詳しく...",
|
||||
"list_with_screenshot_alt": "選択中の機能のスクリーンショット"
|
||||
"link_learn_more": "さらに詳しく..."
|
||||
},
|
||||
"download_now": {
|
||||
"text": "今すぐダウンロード ",
|
||||
@@ -188,5 +191,10 @@
|
||||
"description": "Trilium Notesは、アクセスと管理を容易にする有料サービス PikaPods でホストされています。Trilium チームとは直接関係ありません。",
|
||||
"download_pikapod": "PikaPods にセットアップする",
|
||||
"download_triliumcc": "または、trilium.cc を参照してください"
|
||||
},
|
||||
"header": {
|
||||
"get-started": "はじめる",
|
||||
"documentation": "ドキュメント",
|
||||
"support-us": "サポート"
|
||||
}
|
||||
}
|
||||
@@ -95,8 +95,7 @@
|
||||
"get_started": "Start"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "Dowiedz się więcej....",
|
||||
"list_with_screenshot_alt": "Zrzut ekranu wybranej funkcji"
|
||||
"link_learn_more": "Dowiedz się więcej...."
|
||||
},
|
||||
"download_now": {
|
||||
"text": "Pobierz teraz ",
|
||||
@@ -95,8 +95,7 @@
|
||||
"get_started": "Începe"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "Mai multe detalii...",
|
||||
"list_with_screenshot_alt": "Captură de ecran a funcției selectate"
|
||||
"link_learn_more": "Mai multe detalii..."
|
||||
},
|
||||
"download_now": {
|
||||
"text": "Descărcați acum ",
|
||||
@@ -107,9 +106,9 @@
|
||||
"more_platforms": "Mai multe platforme și instalarea server-ului"
|
||||
},
|
||||
"header": {
|
||||
"get-started": "Primii pași",
|
||||
"documentation": "Documentație",
|
||||
"support-us": "Sprijină-ne"
|
||||
"get-started": "Primii pași",
|
||||
"documentation": "Documentație",
|
||||
"support-us": "Sprijină-ne"
|
||||
},
|
||||
"footer": {
|
||||
"copyright_and_the": " și ",
|
||||
@@ -51,7 +51,8 @@
|
||||
"mermaid_description": "使用 Mermaid 語法繪製流程圖、類別圖與序列圖、甘特圖等多種圖表。",
|
||||
"mindmap_title": "心智圖",
|
||||
"mindmap_description": "以視覺方式整理思緒,或進行腦力激盪。",
|
||||
"others_list": "及其他項目:<0>筆記地圖</0>、<1>關聯地圖</1>、<2>儲存搜尋</2>、<3>渲染筆記</3>,以及<4>網頁檢視</4>。"
|
||||
"others_list": "及其他項目:<0>筆記地圖</0>、<1>關聯地圖</1>、<2>儲存搜尋</2>、<3>渲染筆記</3>,以及<4>網頁檢視</4>。",
|
||||
"title": "多種方式呈現您的資訊"
|
||||
},
|
||||
"extensibility_benefits": {
|
||||
"title": "分享及擴展性",
|
||||
@@ -72,7 +73,10 @@
|
||||
"board_title": "看板",
|
||||
"board_description": "將您的任務或專案狀態整理成看板,輕鬆建立新項目與欄位,並透過在看板上拖曳即可簡單變更狀態。",
|
||||
"geomap_title": "地理地圖",
|
||||
"geomap_description": "使用可自訂的標記,直接在地圖上規劃您的假期行程或標記感興趣的地點。顯示已記錄的GPX軌跡,以便追蹤行程路線。"
|
||||
"geomap_description": "使用可自訂的標記,直接在地圖上規劃您的假期行程或標記感興趣的地點。顯示已記錄的GPX軌跡,以便追蹤行程路線。",
|
||||
"title": "集合",
|
||||
"presentation_title": "簡報",
|
||||
"presentation_description": "將資訊整理成投影片,並以全螢幕模式及流暢的轉場效果呈現。投影片亦可匯出為 PDF 格式,方便分享。"
|
||||
},
|
||||
"faq": {
|
||||
"title": "常見問題",
|
||||
@@ -95,8 +99,7 @@
|
||||
"get_started": "上手指南"
|
||||
},
|
||||
"components": {
|
||||
"link_learn_more": "了解更多…",
|
||||
"list_with_screenshot_alt": "已選擇功能的螢幕截圖"
|
||||
"link_learn_more": "了解更多…"
|
||||
},
|
||||
"download_now": {
|
||||
"text": "馬上下載 ",
|
||||
@@ -188,5 +191,10 @@
|
||||
"description": "Trilium Notes 託管於 PikaPods,此為付費服務,提供便捷存取與管理功能。與 Trilium 團隊無直接關聯。",
|
||||
"download_pikapod": "在 PikaPods 上設定",
|
||||
"download_triliumcc": "或參見 trilium.cc"
|
||||
},
|
||||
"header": {
|
||||
"get-started": "上手指南",
|
||||
"documentation": "文件",
|
||||
"support-us": "支持我們"
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,9 @@
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact",
|
||||
"skipLibCheck": true,
|
||||
"types": [
|
||||
"vite/client"
|
||||
],
|
||||
"paths": {
|
||||
"react": ["../../node_modules/preact/compat/"],
|
||||
"react-dom": ["../../node_modules/preact/compat/"]
|
||||
|
||||
Reference in New Issue
Block a user