feat(ui): add framework-neutral localization support

- add a lightweight UI i18n provider with translation and locale contexts\n- localize accessibility labels across breadcrumb, carousel, dialog, pagination, sheet, sidebar, spinner, and toast components\n- integrate calendar locale data without coupling UI components to Lingui\n- publish tree-shakeable catalogs for eight common locales
This commit is contained in:
Maofeng
2026-07-30 14:47:51 +08:00
parent 0768e8fa29
commit ae1798f6f4
20 changed files with 551 additions and 87 deletions
+14 -8
View File
@@ -4,11 +4,18 @@ import { useRender } from "@base-ui/react/use-render"
import { cn } from "@workspace/ui/lib/utils"
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
import { LocalizedText, uiMessages, useMessage } from "./i18n"
function Breadcrumb({
"aria-label": ariaLabel,
className,
...props
}: React.ComponentProps<"nav">) {
const defaultLabel = useMessage(uiMessages.breadcrumb)
function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
return (
<nav
aria-label="breadcrumb"
aria-label={ariaLabel ?? defaultLabel}
data-slot="breadcrumb"
className={cn(className)}
{...props}
@@ -85,9 +92,7 @@ function BreadcrumbSeparator({
className={cn("[&>svg]:size-3.5", className)}
{...props}
>
{children ?? (
<ChevronRightIcon className="rtl:rotate-180" />
)}
{children ?? <ChevronRightIcon className="rtl:rotate-180" />}
</li>
)
}
@@ -107,9 +112,10 @@ function BreadcrumbEllipsis({
)}
{...props}
>
<MoreHorizontalIcon
/>
<span className="sr-only">More</span>
<MoreHorizontalIcon />
<span className="sr-only">
<LocalizedText message={uiMessages.more} />
</span>
</span>
)
}