Components
UI strings
The text primitives show or announce on their own, in English by default, swappable for the app's translations.
bunx shadcn@latest add @nalarx/ui-stringsSome text sits where a caller never sees it: a skeleton's busy label, a dialog's default buttons, a toast's dismiss button. Items read it from useUIStrings(), so an app wires its translations once instead of passing a label to every instance.
Without a provider
Everything is English (DEFAULT_UI_STRINGS). The Platform app needs nothing.
With a provider
Put one client component near the root that maps the app's i18n to UIStrings. Keys you leave out stay English.
"use client";
import { UIStringsProvider } from "@/components/ui/nx/UIStrings";
import { useTranslation } from "@/hooks/shared/i18n/useTranslation";
export function UIStringsBridge({ children }: { children: React.ReactNode }) {
const { t, language } = useTranslation();
return (
<UIStringsProvider
strings={{
locale: language === "id" ? "id-ID" : "en-US",
close: t("ui.close"),
loading: t("ui.loading"),
// …
}}
>
{children}
</UIStringsProvider>
);
}The same reader outside a provider, then inside one that sets close and retry:
- close
- Close
- retry
- Retry
- pageOf(2, 5)
- Page 2 of 5
- close
- Tutup
- retry
- Coba lagi
- pageOf(2, 5)
- Page 2 of 5
- close
- Close
- retry
- Retry
- pageOf(2, 5)
- Page 2 of 5
- close
- Tutup
- retry
- Coba lagi
- pageOf(2, 5)
- Page 2 of 5
Precedence
A prop on the component (ariaLabel, retryLabel, placeholder…) wins, then the provider, then the English default.
Strings
| Key | Default | Used by |
|---|---|---|
locale | en-US | Date picker |
close | Close | Modal close button, dialogs |
loading | Loading | Skeleton, loading overlay |
retry | Retry | Error state |
ok, cancel, confirm | OK, Cancel, Confirm | App dialog |
typeToConfirmPrefix, typeToConfirmSuffix | Type … to confirm: | App dialog |
selectPlaceholder, searchPlaceholder, searchAriaLabel, noMatches | Select, Search…, Search options, No matches | Select |
toastRegion, dismiss, dismissNotification | Notifications, Dismiss, Dismiss notification | Toast |
paginationLabel, previous, next, rowsPerPage | Pagination, Previous, Next, Rows per page | Pagination |
showingRange(from, to, total), pageOf(page, total), pageNumber(page) | Showing 1–10 of 40, Page 1 of 4, Page 1 | Pagination |
datePlaceholder, today, clear, previousMonth, nextMonth | Pick a date, Today, Clear, Previous month, Next month | Date picker |