Overview
Kiva UI components have built-in i18n support through a provider-agnostic translation system. Components display English by default and automatically switch to the active language when a translation provider is present.
No dependency on any specific i18n library — works with @kivacore/i18n, react-i18next, next-intl, or any custom solution.
Quick Start
1. Wrap your app with UiTranslationProvider
import { UiTranslationProvider } from '@kivacore/ui/hooks/use-ui-translation';
function App() {
return (
<UiTranslationProvider t={yourTranslateFunction}>
{/* All Kiva UI components will now be translated */}
<Calendar events={events} />
<DataGrid table={table} />
</UiTranslationProvider>
);
}The t prop accepts any function with the signature:
(key: string, fallback?: string | Record<string, string | number>) => string2. Without a provider
Components render in English with no setup required:
// No provider needed — English fallback works automatically
<Calendar events={events} />Ready-made catalogs
Kiva UI ships complete catalogs for the ui.* keys in English, Turkish, German and French, so you do not have to translate the library's own copy.
kiva-ui add ui-localesThe files land in locales/kiva/ (en.json, tr.json, de.json, fr.json) as flat key → text maps. Mount one with the messages prop — no i18n library required:
import tr from '@/locales/kiva/tr.json';
import { UiTranslationProvider } from '@/hooks/use-ui-translation';
function AppShell({ children }: { children: React.ReactNode }) {
return (
<UiTranslationProvider messages={tr}>
{children}
</UiTranslationProvider>
);
}For React Native the item is rn-locales and the files land in locales/kiva-native/.
Combining a catalog with your own i18n
Pass both. Your t is consulted first, so anything your app already translates wins; the catalog covers every key you have not translated yourself, and the English source text covers anything neither provides.
<UiTranslationProvider t={t} messages={tr}>
{children}
</UiTranslationProvider>Load the catalog for the active language only — each file is roughly 80 KB. With a bundler that supports it, a dynamic import() keyed on the language keeps the other three out of the initial bundle.
Integration Examples
@kivacore/i18n
import { useKivaI18n } from '@kivacore/i18n';
import { UiTranslationProvider } from '@kivacore/ui/hooks/use-ui-translation';
function AppShell({ children }: { children: React.ReactNode }) {
const { t } = useKivaI18n();
return (
<UiTranslationProvider t={t}>
{children}
</UiTranslationProvider>
);
}react-i18next
import { useTranslation } from 'react-i18next';
import { UiTranslationProvider } from '@kivacore/ui/hooks/use-ui-translation';
function AppShell({ children }: { children: React.ReactNode }) {
const { t } = useTranslation();
return (
<UiTranslationProvider t={t}>
{children}
</UiTranslationProvider>
);
}next-intl
import { useTranslations } from 'next-intl';
import { UiTranslationProvider } from '@kivacore/ui/hooks/use-ui-translation';
function AppShell({ children }: { children: React.ReactNode }) {
const t = useTranslations();
return (
<UiTranslationProvider t={t}>
{children}
</UiTranslationProvider>
);
}Translation Keys
All component translation keys follow the ui.<group>.<camelCaseKey> convention:
| Group | Prefix | Example Key | English Default |
|---|---|---|---|
| Common | ui.common | ui.common.search | Search |
| Calendar | ui.calendar | ui.calendar.addEvent | Add Event |
| Data Grid | ui.dataGrid | ui.dataGrid.filter | Filter |
| Form Fields | ui.formField | ui.formField.selectPlaceholder | Select... |
| Pricing Engine | ui.pricing | ui.pricing.subtotal | Subtotal |
| Mega Select | ui.megaSelect | ui.megaSelect.search | Search |
| Team Chat | ui.teamChat | ui.teamChat.writePost | Write a post... |
| Contact Activity | ui.contactActivity | ui.contactActivity.all | All |
| Log Activity | ui.logActivity | ui.logActivity.taskSubject | Task subject |
| Email Composer | ui.emailComposer | ui.emailComposer.send | Send |
| Record Sharing | ui.recordSharing | ui.recordSharing.share | Share |
| Query Builder | ui.queryBuilder | ui.queryBuilder.columns | Columns |
| Data Grid View | ui.dataGridView | ui.dataGridView.selectView | Select view |
| Time Slot | ui.timeSlot | ui.timeSlot.available | Available |
| Scheduler | ui.scheduler | ui.scheduler.today | Today |
| Agent | ui.agent | ui.agent.sendMessage | Send message |
| Tree View | ui.treeView | ui.treeView.expandAll | Expand All |
| Place Autocomplete | ui.placeAutocomplete | ui.placeAutocomplete.searchPlaces | Search places... |
How It Works
Components use the useUiTranslation hook internally:
import { useUiTranslation } from '@/hooks/use-ui-translation';
function MyComponent() {
const { t } = useUiTranslation();
return (
<button>{t('ui.calendar.addEvent', 'Add Event')}</button>
);
}- First argument: Translation key
- Second argument: English source text — rendered when neither your
tnor the catalog resolves the key - Third argument (optional): runtime values for the
{{name}}placeholders in the text
t('ui.dataGrid.rowsSelected', '{{count}} rows selected', { count })Resolution order, highest first: your t → the messages catalog → the English source text.
Never build the value into the string (t(key, `${count} rows selected`)). That string is the key's English source and the unit of translation — interpolating it produces a different source text on every render, which no catalog can ever match. Keep it templated and pass the values in the third argument.
A translated string must keep exactly the placeholders its source has. pnpm i18n:sync fails the build on any catalog entry that drops, adds or re-spells one.
The provider fills both {{name}} and the older single {name}. Dictionaries written against a call site that used to do its own .replace() keep working unchanged — you do not have to rewrite them when a component moves to the params argument.
Customizing Translations
To override a specific component's text, add the corresponding key to your i18n translation dictionary.
For example, to change the Calendar's "Add Event" button to "New Appointment" in Turkish:
{
"ui.calendar.addEvent": "Yeni Randevu"
}Any key not present in your dictionary will fall back to the English default embedded in the component.
Date Formatting
Kiva UI components do not format dates — they display raw values by default. To show formatted dates (e.g. DD/MM/YYYY or MM/DD/YYYY), wrap your app with DateFormatProvider.
Setup
import { DateFormatProvider } from '@kivacore/ui/hooks/use-date-format';
import { format } from 'date-fns';
function App() {
return (
<DateFormatProvider
formatDate={(v) => format(new Date(String(v)), 'dd/MM/yyyy')}
formatDateTime={(v) => format(new Date(String(v)), 'dd/MM/yyyy HH:mm')}
formatTime={(v) => format(new Date(`1970-01-01T${v}`), 'HH:mm')}
>
<Calendar events={events} />
<DataGrid table={table} />
</DateFormatProvider>
);
}Works with any date library — date-fns, dayjs, Intl.DateTimeFormat, or plain functions.
Per-component override
Some components accept formatDate / formatDateTime props directly for per-instance customization:
<DataGrid
table={table}
formatDate={(v) => dayjs(v).format('MM/DD/YYYY')}
formatDateTime={(v) => dayjs(v).format('MM/DD/YYYY h:mm A')}
/>Per-component props take precedence over the provider.
Without a provider
Components display raw values (e.g. 2026-04-13 or 2026-04-13T10:30:00.000Z) with no formatting applied.
useDateFormat hook
import { useDateFormat } from '@kivacore/ui/hooks/use-date-format';
function MyComponent() {
const { formatDate, formatDateTime, formatTime } = useDateFormat();
return <span>{formatDate(someDate)}</span>;
}API Reference
UiTranslationProvider
| Prop | Type | Description |
|---|---|---|
t | (key: string, fallback?: string | Record<string, string | number>) => string | Translation function from your i18n library |
children | ReactNode | Child components |
useUiTranslation
function useUiTranslation(): { t: TranslateFn }Returns { t } where t(key, fallback) resolves to:
- Translated string from provider (if available)
- English fallback string (if no provider or key not found)
DateFormatProvider
| Prop | Type | Description |
|---|---|---|
formatDate | (value: unknown) => string | Format a date value for display |
formatDateTime | (value: unknown) => string | Format a datetime value for display |
formatTime | (value: unknown) => string | Format a time value for display |
children | ReactNode | Child components |
useDateFormat
function useDateFormat(): {
formatDate: (value: unknown) => string;
formatDateTime: (value: unknown) => string;
formatTime: (value: unknown) => string;
}Returns formatters from DateFormatProvider. Without a provider, all formatters return the raw value as a string.