Skip to content

fix(web): localize design-system import errors (#2686)#6075

Open
arseniy-gl wants to merge 2 commits into
nexu-io:mainfrom
arseniy-gl:fix/i18n-design-system-import-error
Open

fix(web): localize design-system import errors (#2686)#6075
arseniy-gl wants to merge 2 commits into
nexu-io:mainfrom
arseniy-gl:fix/i18n-design-system-import-error

Conversation

@arseniy-gl

Copy link
Copy Markdown
Contributor

Fixes #2686

Why

When a design system import fails, the daemon returns an English error message and the Settings form shows it as-is. Every non-English locale (zh-CN, ru, fr, de, and 15 others) sees English text inside an otherwise fully localized UI. The issue was reported by a Chinese user, but the bug affects all 19 locales.

I found this while looking for a good first issue after my first contribution (#5836). The scope matched what @lefarcen described in the issue: a UI-side fix that maps the daemon error code to a localized key.

What users will see

  • When a design system import fails (local path, GitHub URL, or shadcn reference), the Settings form now shows a localized error message instead of the raw English text from the daemon.
  • The raw daemon message (with the actual path or URL) is still available under a Details disclosure for diagnostics.
  • English locale is unchanged — it shows the same localized English text.
  • Unknown error codes (not BAD_REQUEST or INTERNAL_ERROR) fall back to the raw message, same as before.

Surface area

  • UI
  • Keyboard shortcut
  • CLI / env var
  • API / contract
  • Extension point
  • i18n keys — 3 new keys (designSystemsImportErrorInvalid, designSystemsImportErrorInternal, designSystemsImportErrorDetails) added to types.ts and all 19 locale files
  • New top-level dependency
  • Default behavior change — import error text is now localized and wrapped in a details disclosure instead of shown as raw English
  • None

Screenshots

No new UI surface — the change is in the error text that appears in the existing import form. The layout and controls are unchanged.

Bug fix verification

  • Test path: apps/web/tests/components/DesignSystemsSection.test.tsx — new describe block "import error localization (issue Chinese UI still shows English error messages in the design system import flow #2686)"
  • Did the test go red on main and green on this branch? yes
    • On main: the test fails because the raw English text local project path must be a directory is rendered in the Chinese UI
    • On this branch: the test passes — the Chinese summary "无法导入设计系统" is shown, and the raw detail is under <details>
  • Unit test for the code-to-key mapping: apps/web/tests/runtime/design-system-import-error.test.ts

Validation

  • pnpm --filter @open-design/web typecheck — clean (catches missing locale entries via the typed Dict)
  • pnpm --filter @open-design/web test — 4768 passed, 439 files
  • pnpm guard — only pre-existing apps/telemetry-worker ENOENT failure (same as main, verified via stash)

Adjacent issues

The same raw-English-error pattern exists in apps/web/src/components/SkillsSection.tsx:360,394 (setDraftError(result.error.message) without localization). That is a separate surface with its own error categories — out of scope for this PR. I will file a follow-up issue.

…or shown in zh-CN

A failing test in DesignSystemsSection.test.tsx anchors the bug: when the
daemon rejects a design-system import (e.g. BAD_REQUEST from a local path
check), the Settings form renders the raw `result.error.message` (English)
directly in the Chinese UI.

The fix will route the error envelope through a localized formatter
(formatDesignSystemImportError) that maps `code` → i18n key and keeps the
raw detail under a <details> disclosure. Refs nexu-io#2686.
The daemon returns English error messages for design-system import
failures, and the Settings form rendered them raw — so every non-English
locale saw English text in an otherwise localized UI.

The fix routes the error envelope through `designSystemImportErrorKey`,
which maps `code` (`BAD_REQUEST` / `INTERNAL_ERROR`) to a new i18n
key. The localized summary replaces the raw English as the user-facing
message, while the raw daemon detail (paths, URLs) remains accessible
under a <details> disclosure for diagnostics.

- New runtime helper: `apps/web/src/runtime/design-system-import-error.ts`
- 3 new i18n keys across all 19 locales
- Component change: `DesignSystemsSection.tsx` stores the full error
  envelope (with `code`) instead of just the message string
- Red spec: `DesignSystemsSection.test.tsx` proves the raw English is
  no longer the primary visible text in zh-CN
- Unit tests for the code-to-key mapping

Fixes nexu-io#2686
@lefarcen

Copy link
Copy Markdown
Contributor

Thanks @arseniy-gl — good catch localizing the import failure summary while still keeping the raw daemon detail available for debugging. I'll route the PR through the usual triage steps now and keep the thread updated if anything needs action from your side.

@lefarcen lefarcen added the size/M PR changes 100-300 lines label Jul 25, 2026
@lefarcen
lefarcen requested a review from PerishCode July 25, 2026 16:26
@lefarcen lefarcen added risk/medium Medium risk: regular code changes type/bugfix Bug fix skip-validation Maintainer override: bot will not auto-add needs-validation on this PR. labels Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/medium Medium risk: regular code changes size/M PR changes 100-300 lines skip-validation Maintainer override: bot will not auto-add needs-validation on this PR. type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chinese UI still shows English error messages in the design system import flow

2 participants