⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat(web): localize Mermaid rendering errors
Slainefe53531ece5
diff --git a/apps/web/src/components/activity/comment-editor.tsx b/apps/web/src/components/activity/comment-editor.tsxindex 3b0dfe364..5b9f360fe 100644--- a/apps/web/src/components/activity/comment-editor.tsx+++ b/apps/web/src/components/activity/comment-editor.tsx@@ -623,7 +623,9 @@ export default function CommentEditor({themeDark: "github-dark",themeLight: "github-light",}),- MermaidBlock,+ MermaidBlock.configure({+ errorKey: "activity:comment.editor.mermaid.renderFailed",+ }),EmbedBlock,AttachmentCard,KaneoIssueLink,diff --git a/apps/web/src/components/task/extensions/mermaid-block.ts b/apps/web/src/components/task/extensions/mermaid-block.tsindex 42b8a6d33..9b5ef2f6f 100644--- a/apps/web/src/components/task/extensions/mermaid-block.ts+++ b/apps/web/src/components/task/extensions/mermaid-block.ts@@ -11,6 +11,7 @@ import { isDarkTheme, SHIKI_CODEBLOCK_REFRESH_META } from "./shiki-code-block";const MERMAID_LANGUAGE = "mermaid";const MERMAID_REFRESH_META = "mermaid-refresh";+const DEFAULT_ERROR_KEY = "tasks:detail.editor.mermaid.renderFailed";const RENDER_DEBOUNCE_MS = 250;const RENDER_CACHE_LIMIT = 20;const mermaidPluginKey = new PluginKey("mermaid-block");@@ -19,6 +20,10 @@ type RenderState =| { status: "done"; svg: string }| { status: "error"; message: string };+type MermaidBlockOptions = {+ errorKey: string;+};+type Scheduler = {want: (cacheKey: string,@@ -83,7 +88,7 @@ async function renderMermaid(code: string, dark: boolean) {});}-function createScheduler(onSettled: () => void): Scheduler {+function createScheduler(errorKey: string, onSettled: () => void): Scheduler {const wanted = new Map<string,{ code: string; dark: boolean; explicit: boolean }@@ -109,9 +114,7 @@ function createScheduler(onSettled: () => void): Scheduler {error instanceof Error ? error.message : String(error);cacheRender(key, { status: "error", message });if (explicit && active) {- toast.error(i18n.t("tasks:detail.editor.mermaid.renderFailed"), {- description: message,- });+ toast.error(i18n.t(errorKey), { description: message });}}}),@@ -122,7 +125,11 @@ function createScheduler(onSettled: () => void): Scheduler {return {want: (cacheKey, code, dark, explicit) =>- wanted.set(cacheKey, { code, dark, explicit }),+ wanted.set(cacheKey, {+ code,+ dark,+ explicit: explicit || wanted.get(cacheKey)?.explicit === true,+ }),reset: () => wanted.clear(),flush: () => {if (wanted.size > 0) flush();@@ -192,13 +199,17 @@ function getDecorations(doc: ProseMirrorNode, scheduler: Scheduler) {return DecorationSet.create(doc, decorations);}-export const MermaidBlock = Extension.create({+export const MermaidBlock = Extension.create<MermaidBlockOptions>({name: "mermaidBlock",+ addOptions() {+ return { errorKey: DEFAULT_ERROR_KEY };+ },+addProseMirrorPlugins() {const editor = this.editor;- const scheduler = createScheduler(() => {+ const scheduler = createScheduler(this.options.errorKey, () => {const { view } = editor;if (!view || view.isDestroyed) return;view.dispatch(view.state.tr.setMeta(MERMAID_REFRESH_META, true));diff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex 0f7b63b4f..bf12e64bf 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -1307,6 +1307,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Mermaid-Diagramm konnte nicht gerendert werden"}}}diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex d9d05cf94..d88bb6db7 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -1265,6 +1265,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Δεν ήταν δυνατή η απόδοση του διαγράμματος Mermaid"}}}diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex 0723a3cae..cbf722ffd 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -1471,6 +1471,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Mermaid diagram couldn't be rendered"}}}diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex 5314f84dd..89bc5af6d 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -1050,6 +1050,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "No se pudo renderizar el diagrama de Mermaid"}}}diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex 75bb0a3cb..ae4773b05 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -1273,6 +1273,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Impossible d'afficher le diagramme Mermaid"}}}diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex 4204182a7..9d1fe9a40 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -1410,6 +1410,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Diagram Mermaid tidak dapat dirender"}}}diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex d495e7168..b3f2997b6 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -1267,6 +1267,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Mermaid 다이어그램을 렌더링할 수 없습니다"}}}diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex 74bc4b5e0..5fa880d94 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -1265,6 +1265,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Mermaid дијаграмот не можеше да се прикаже"}}}diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex e0c69c16e..f4903b2d6 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -1051,6 +1051,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Mermaid-diagram kon niet worden weergegeven"}}}diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex 6f397ca55..b794ea8d4 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -1270,6 +1270,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Не удалось отобразить диаграмму Mermaid"}}}diff --git a/i18n/schema.json b/i18n/schema.jsonindex 31be942ab..f57adeddd 100644--- a/i18n/schema.json+++ b/i18n/schema.json@@ -5551,6 +5551,16 @@"typescript","yaml"]+ },+ "mermaid": {+ "type": "object",+ "additionalProperties": false,+ "properties": {+ "renderFailed": {+ "type": "string"+ }+ },+ "required": ["renderFailed"]}},"required": [@@ -5601,7 +5611,8 @@"copied","dropImageToUpload","previewImageAlt",- "codeLang"+ "codeLang",+ "mermaid"]}},diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex cdb35de7d..89540a94f 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -1272,6 +1272,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Mermaid diyagramı oluşturulamadı"}}}diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex 061b94c6c..d9613b86d 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -1264,6 +1264,9 @@"swift": "Swift","typescript": "TypeScript","yaml": "YAML"+ },+ "mermaid": {+ "renderFailed": "Не вдалося відобразити діаграму Mermaid"}}}