fix(web): localize design-system import errors (#2686) - #6075
Conversation
|
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. |
โฆ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
9363ae7 to
8cf1434
Compare
PerishCode
left a comment
There was a problem hiding this comment.
The error-code mapping and raw diagnostic disclosure are well scoped, and the added tests cover the intended localized summary behavior. I found two merge-safe issues in the changed UI and locale ranges that should be corrected.
๐ Powered by Looper ยท runner=reviewer ยท agent=codex ยท An autonomous AI dev team for your GitHub repos.| {importError ? ( | ||
| <p className="library-install-error"> | ||
| {importErrorKey ? t(importErrorKey) : importError.message} | ||
| <details className="library-install-error-detail"> |
There was a problem hiding this comment.
Use a flow-content container for the error block instead of nesting <details> inside <p>. A <details> element is not permitted paragraph content, so this markup triggers React's invalid DOM-nesting warning and can be reparsed differently when serialized or hydrated. Change the outer element to a <div className="library-install-error"> (and wrap the summary text in a span or paragraph if its styling needs a text node) while keeping the disclosure as its sibling child.
| 'settings.designSystemsImportedStatus': '{title} ๊ฐ์ ธ์ด', | ||
| 'settings.designSystemsViewImported': '๊ฐ์ ธ์จ ๋์์ธ ์์คํ ๋ณด๊ธฐ', | ||
| 'settings.designSystemsImportErrorInvalid': '๋์์ธ ์์คํ ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. ๊ฒฝ๋ก ๋๋ URL์ ํ์ธํ๊ณ ๋ค์ ์๋ํ์ธ์.', | ||
| 'settings.designSystemsImportErrorInternal': '๋ธ๋ถ ์ค๋ฅ๋ก ์ธํด ๋์์ธ ์์คํ ์ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค. ๋ค์ ์๋ํ์ธ์.', |
There was a problem hiding this comment.
Correct the Korean word for โinternalโ from ๋ธ๋ถ to ๋ด๋ถ. The current typo is directly user-visible in the newly localized internal-error message and makes the sentence read incorrectly; the value should begin ๋ด๋ถ ์ค๋ฅ๋ก ์ธํด ....
|
Hey @arseniy-gl โ @PerishCode left two concrete fixes on the current head that are worth addressing before the next pass: the ๐ก To drive this PR to merge hands-free, paste this to your AI coding agent (Claude Code / Codex / opencode / Cursor โฆ): |
- Replace <p> wrapper with <div> around import error block to avoid invalid <details> nesting inside <p> - Fix Korean internal error message: ๋ธ๋ถ โ ๋ธ๋ถ (U+B0B8 โ U+B0B4)
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
BAD_REQUESTorINTERNAL_ERROR) fall back to the raw message, same as before.Surface area
designSystemsImportErrorInvalid,designSystemsImportErrorInternal,designSystemsImportErrorDetails) added totypes.tsand all 19 locale filesScreenshots
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
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)"mainand green on this branch? yesmain: the test fails because the raw English textlocal project path must be a directoryis rendered in the Chinese UI<details>apps/web/tests/runtime/design-system-import-error.test.tsValidation
pnpm --filter @open-design/web typecheckโ clean (catches missing locale entries via the typedDict)pnpm --filter @open-design/web testโ 4768 passed, 439 filespnpm guardโ only pre-existingapps/telemetry-workerENOENT failure (same asmain, 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.