Skip to Content
Guide

Internationalization (i18n)

How to add multi-language support to Kiva UI components.

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>) => string

2. 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-locales

The 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:

GroupPrefixExample KeyEnglish Default
Commonui.commonui.common.searchSearch
Calendarui.calendarui.calendar.addEventAdd Event
Data Gridui.dataGridui.dataGrid.filterFilter
Form Fieldsui.formFieldui.formField.selectPlaceholderSelect...
Pricing Engineui.pricingui.pricing.subtotalSubtotal
Mega Selectui.megaSelectui.megaSelect.searchSearch
Team Chatui.teamChatui.teamChat.writePostWrite a post...
Contact Activityui.contactActivityui.contactActivity.allAll
Log Activityui.logActivityui.logActivity.taskSubjectTask subject
Email Composerui.emailComposerui.emailComposer.sendSend
Record Sharingui.recordSharingui.recordSharing.shareShare
Query Builderui.queryBuilderui.queryBuilder.columnsColumns
Data Grid Viewui.dataGridViewui.dataGridView.selectViewSelect view
Time Slotui.timeSlotui.timeSlot.availableAvailable
Schedulerui.schedulerui.scheduler.todayToday
Agentui.agentui.agent.sendMessageSend message
Tree Viewui.treeViewui.treeView.expandAllExpand All
Place Autocompleteui.placeAutocompleteui.placeAutocomplete.searchPlacesSearch 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 t nor 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.

API Reference

UiTranslationProvider

PropTypeDescription
t(key: string, fallback?: string | Record<string, string | number>) => stringTranslation function from your i18n library
childrenReactNodeChild 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)

On this page