dimah-s3v1.5.4

Internationalization

English by default. Pass a partial map to localize.

English needs no setup. To localize, put a map in a file and pass it to the provider.

lib/translations-fa.ts
import type { Translations } from "@dimah-s3/react";

export const fa = {
  "Upload failed(toast)": "آپلود ناموفق بود",
  "Cancel(dialog button)": "لغو",
} satisfies Partial<Translations>;
lib/s3-client.ts
"use client";

import { createS3Client } from "@dimah-s3/react";

export const s3Client = createS3Client();
export const S3Provider = s3Client.Provider;
app/layout.tsx
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 / other all-client apps can pass translations on <s3Client.Provider> instead.

Missing keys stay English.

API errors

The server always responds in English. With @dimah-s3/ui or the React hooks you do not need anything else — the same translations map localizes those messages.

On this page