Get started
Localization
LocaleProvider sets the language of every component: built-in labels and screen-reader text, date and number formats, plurals, and writing direction. 32 languages are bundled, and you can add your own.
Try it
Pick a language. Every built-in word below comes from the library: the empty state, the upload prompt, the month and weekday names, the currency format, and the pagination's screen-reader labels. The field labels ("Project images", "Budget") are this page's own text, so they follow the site's language, not the demo's.
locale="es" · dir="ltr"
No results for “blue sneakers”
Try a different search or clear your filters.
Drop files here or browse
Images.
octubre de 2026
| lun | mar | mié | jue | vie | sáb | dom |
|---|---|---|---|---|---|---|
import es from "@vjdesigns/vjdesigns-ui/locales/es";
<LocaleProvider locale="es" messages={es}>
<App />
</LocaleProvider>
Set the language
Wrap your app in LocaleProvider with a locale and its messages. Each language is a separate import, so your app only downloads the ones it uses. Without a provider, components use English text and the browser's date and number format.
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import es from "@vjdesigns/vjdesigns-ui/locales/es";
<LocaleProvider locale="es" messages={es}>
<App />
</LocaleProvider>
LocaleProvider sets the built-in text, date and number formats, plural rules, writing direction, and the lang attribute (so screen readers pronounce the text correctly). Menus, dialogs and tooltips keep the language of the area that opened them.
What gets translated
The library translates only its own built-in text. Text your app passes in, like <Button>Save</Button>, is your content: translate it with your app's i18n library (react-i18next, FormatJS and so on).
| Text | Translated? |
|---|---|
| Text your app passes in, like button labels and field labels | No: your app translates it |
| Built-in names, like "Close", "Next page", "Clear search" | Yes: "Schließen", "Nächste Seite", "Suche löschen" |
| Screen-reader announcements, like "3 results available" | Yes: "3 Ergebnisse verfügbar" |
| Validation messages, empty states, file-upload prompts | Yes |
| Dates and numbers | Yes: "23.10.2026", "4,5" |
Dates, times and numbers
Formats follow the full locale, region included, not just the language: en-US and en-GB share English text but write dates differently. Pick a region to see the date field, calendar, time field and currency change. Built-in text stays in English here, so only the formats change; add messages to translate it too. This works without any messages at all, so <LocaleProvider locale="en-GB"> alone gives British formats.
locale="en-GB"
October 2026
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
// Your app gets the same values in every region:
// date: "2026-10-24", time: "14:30", price: 2500.5
<LocaleProvider locale="en-GB">
<App />
</LocaleProvider>
| Setting | Examples | Override |
|---|---|---|
| Typed date format | 10/24/2026 (en-US), 24/10/2026 (en-GB), 24.10.2026 (de), 2026/10/24 (ja) | locale on the component |
| First day of the week | Sunday (en-US, ja, pt-BR), Monday (en-GB, de, fr), Saturday (ar-EG) | weekStartsOn |
| Month and weekday names | October, Oktober, octobre, 10月 | locale on the component |
| 12 or 24 hour clock | 2:30 PM (en-US), 14:30 (en-GB, de, ja) | hourCycle |
| Numbers and currency | €2,500.50 (en), 2.500,50 € (de), 2 500,50 € (fr) | formatOptions on NumberInput |
Values never change with the locale or time zone: a date is always "2026-10-24" and a time "14:30", so your server and database see one format. People can type the local format or an ISO date in any region. The typed field uses the Gregorian calendar and Western digits (0 to 9) everywhere, so dates stay easy to enter and to check.
Bundled languages
English is built in. These 31 languages ship with the package; import each from @vjdesigns/vjdesigns-ui/locales/<code>.
arArabicbnBengalicsCzechdaDanishdeGermanelGreekesSpanishfaPersianfiFinnishfrFrenchheHebrewhiHindihuHungarianidIndonesianitItalianjaJapanesekoKoreannbNorwegian BokmålnlDutchplPolishpt-BRPortuguese (Brazil)roRomanianruRussiansvSwedishthThaitrTurkishukUkrainianurUrduviVietnamesezh-HansChinese (Simplified)zh-HantChinese (Traditional)
The translations are machine-generated and haven't been reviewed by native speakers yet. If a phrase is wrong or awkward, override it (below) and report it so the bundled locale can be fixed.
Change a few strings
Pass only the strings you want to change. Providers nest, so an inner provider can also switch the language for one part of the page. Per-component props such as clearLabel or labels still win over the provider.
// Change just a few strings; everything else falls back to the
// outer provider's language (English at the top).
<LocaleProvider locale="en-GB" messages={{ pagination: { next: "Onwards" } }}>
<App />
</LocaleProvider>
// Providers nest: one section of the page can use another language.
<LocaleProvider locale="en">
<Header />
<LocaleProvider locale="fr" messages={fr}>
<FrenchStorefront />
</LocaleProvider>
</LocaleProvider>
Add another language
For a language that isn't bundled, write a complete Messages object, using English as the template. plural(locale) picks the right plural form for any language; # is the formatted number.
import { en, plural, type Messages } from "@vjdesigns/vjdesigns-ui";
const p = plural("sw");
// Start from English; TypeScript flags any string you miss.
export const sw: Messages = {
...en,
pagination: { ...en.pagination, next: "Ukurasa unaofuata", previous: "Ukurasa uliopita" },
searchInput: {
...en.searchInput,
results: (count) => p(count, { "=0": "Hakuna matokeo", one: "Tokeo #", other: "Matokeo #" }),
},
// ...
};
Switch language at runtime
List your languages as loaders so each one downloads only when it's picked. This page's demo works this way.
import { useEffect, useState } from "react";
import { LocaleProvider, type Messages } from "@vjdesigns/vjdesigns-ui";
// Each language downloads only when someone picks it.
const loaders: Record<string, () => Promise<{ default: Messages }>> = {
es: () => import("@vjdesigns/vjdesigns-ui/locales/es"),
fr: () => import("@vjdesigns/vjdesigns-ui/locales/fr"),
ar: () => import("@vjdesigns/vjdesigns-ui/locales/ar"),
};
export function LocalizedApp({ lang }: { lang: string }) {
const [messages, setMessages] = useState<Messages>();
useEffect(() => {
const load = loaders[lang];
if (load) load().then((mod) => setMessages(mod.default));
else setMessages(undefined); // English
}, [lang]);
// Until a language loads, the previous one (or English) shows.
return (
<LocaleProvider locale={lang} messages={messages}>
<App />
</LocaleProvider>
);
}
// The library never guesses the language. To follow the browser's,
// pass it in yourself (with the matching messages):
<LocalizedApp lang={navigator.language} />
Right-to-left languages
Arabic, Hebrew, Persian and Urdu get dir="rtl" automatically: layouts mirror, and arrow keys follow the reading direction. Pass dir to override it. Pick العربية or עברית in the demo to see it. Spacing tokens use logical properties, so your own styles mirror too if you use margin-inline-start rather than margin-left; see Design tokens.
Read the current language
useLocale() returns the locale and direction from the nearest provider, and useMessages() the built-in strings, for your own components that need them.
import { getLocaleDirection, useLocale, useMessages } from "@vjdesigns/vjdesigns-ui";
function Toolbar() {
const { locale, dir } = useLocale(); // "ar", "rtl"
const messages = useMessages(); // the built-in strings in effect
// ...
}
// For server rendering, set lang and dir on <html> yourself:
const dir = getLocaleDirection("he"); // "rtl"
LocaleProvider API
| Prop | Type | Default |
|---|---|---|
localeRequiredNew in 1.3.0BCP 47 language tag, e.g. | string | — |
messagesNew in 1.3.0Built-in strings for the language, e.g. | PartialMessages | — |
dirNew in 1.3.0Writing direction. Defaults to the locale's: | "ltr""rtl" | — |
childrenNew in 1.3.0 | ReactNode | — |