From 46c2fcc56885f8232d9c655a0a58793ebc309bea Mon Sep 17 00:00:00 2001 From: hqhq1025 <1506751656@qq.com> Date: Sun, 19 Apr 2026 05:00:32 +0800 Subject: [PATCH] fix(desktop): i18n ErrorBoundary fallback strings --- .../renderer/src/components/ErrorBoundary.tsx | 78 ++++++++++++------- .../src/components/InlineCommentComposer.tsx | 3 +- packages/i18n/src/locales/en.json | 8 ++ packages/i18n/src/locales/zh-CN.json | 8 ++ 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/apps/desktop/src/renderer/src/components/ErrorBoundary.tsx b/apps/desktop/src/renderer/src/components/ErrorBoundary.tsx index 45f1715a9..320409d5b 100644 --- a/apps/desktop/src/renderer/src/components/ErrorBoundary.tsx +++ b/apps/desktop/src/renderer/src/components/ErrorBoundary.tsx @@ -11,6 +11,7 @@ * preview / topbar) so a single crash never blanks the entire window. */ +import { useT } from '@open-codesign/i18n'; import { Button } from '@open-codesign/ui'; import { Component, type ErrorInfo, type ReactNode } from 'react'; @@ -79,41 +80,58 @@ export class ErrorBoundary extends Component -
-
- {scope} crashed -
-

- {error.name}: {error.message} -

-

- The rest of the app is still running. Reload this view, or copy the stack to file a bug. -

-
-            {error.stack ?? '(no stack)'}
-          
-
- - -
-
- + void this.copyStack()} + /> ); } } +interface ErrorBoundaryFallbackProps { + error: Error; + scope?: string | undefined; + onReset: () => void; + onCopyStack: () => void; +} + +function ErrorBoundaryFallback({ + error, + scope, + onReset, + onCopyStack, +}: ErrorBoundaryFallbackProps): ReactNode { + const t = useT(); + const scopeLabel = scope ?? t('errorBoundary.scopeFallback'); + return ( +
+
+
+ {t('errorBoundary.crashedSuffix', { scope: scopeLabel })} +
+

+ {error.name}: {error.message} +

+

{t('errorBoundary.body')}

+
+          {error.stack ?? t('errorBoundary.noStack')}
+        
+
+ + +
+
+
+ ); +} + function ErrorBoundaryChildren({ children }: { children: ReactNode }): ReactNode { return children; } diff --git a/apps/desktop/src/renderer/src/components/InlineCommentComposer.tsx b/apps/desktop/src/renderer/src/components/InlineCommentComposer.tsx index 3735dff6a..880ee337d 100644 --- a/apps/desktop/src/renderer/src/components/InlineCommentComposer.tsx +++ b/apps/desktop/src/renderer/src/components/InlineCommentComposer.tsx @@ -33,7 +33,8 @@ function InlineCommentComposerCard({ selectedElement }: InlineCommentComposerCar
- {t('inlineComment.title')} {selectedElement.tag} + {t('inlineComment.title')}{' '} + {selectedElement.tag}