Internationalization
Localize React UI strings with a partial translation map.
English needs no setup. To localize the React client, define a partial translation map and pass it to the provider.
import type { Translations } from "@dimah-s3/react";
export const fa = {
"Upload failed(toast)": "آپلود ناموفق بود",
"Cancel(dialog button)": "لغو",
} satisfies Partial<Translations>; "use client";
import { createS3Client } from "@dimah-s3/react";
export const s3Client = createS3Client();
export const S3Provider = s3Client.Provider;import { S3Provider } from "@/lib/s3-client";
import { fa } from "@/lib/translations-fa";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="fa" dir="rtl">
<body>
<S3Provider translations={fa}>{children}</S3Provider>
</body>
</html>
);
}Vite and other client-only apps can pass translations to
<s3Client.Provider> instead.
Missing keys stay English.
Numbers and sizes
Pass locale to the provider for native digits in sizes, counts, and
progress. Unit labels are translation keys, so the same map can rename them:
export const fa = {
"KB(file size unit)": "کیلوبایت",
"MB(file size unit)": "مگابایت",
"GB(file size unit)": "گیگابایت",
} satisfies Partial<Translations>;<S3Provider translations={fa} locale="fa">
{children}
</S3Provider>Sizes then read ۱۲٫۴ مگابایت. Without locale, they read 12.4 MB. Your
own components can use the same formatters with useFormatFileSize() and
useFormatNumber() from @dimah-s3/react.
API errors
The server always responds in English. @dimah-s3/ui localizes errors with the
same translations map. Headless hooks expose the original APIError; pass it
to useFormatDimahError before rendering a localized
message.