# Internationalization (i18n)

AIKit localizes user-facing strings on a **per-component** basis using `@gravity-ui/i18n`. There is no global i18n provider — each component bundles its own keyset.

Out-of-the-box languages: **English (`en`)** and **Russian (`ru`)**.

## How It Works

Each localized component contains an `i18n/` directory:

```
ComponentName/
├── i18n/
│   ├── index.ts      # registers the keyset with @gravity-ui/i18n
│   ├── en.json
│   └── ru.json
```

The keyset is registered under a namespace derived from the component's name. At runtime, `@gravity-ui/i18n` resolves strings against the active language (set via `configure({lang})`).

## Setting the Language

```typescript
import {configure} from '@gravity-ui/i18n';

configure({lang: 'ru'}); // or 'en'
```

Call this once at application bootstrap, before rendering AIKit components.

## Overriding Strings

Every component that has user-visible text also exposes a `texts` prop (or per-feature prop like `headerProps.texts`) for per-instance overrides. `ChatContainer` aggregates these via a single `texts` prop on the page level. The resolution order is:

1. `texts.<key>` on the component (or on `ChatContainer`)
2. Custom keyset registered with `@gravity-ui/i18n` (if you override the bundled one)
3. AIKit's bundled `i18n/<lang>.json` defaults

## Adding a Custom Language

Re-register the bundled keysets with your translations:

```typescript
import {addKeysets} from '@gravity-ui/i18n';
import esTabs from './my-translations/Tabs.es.json';

addKeysets('es', {
  'aikit.Tabs': esTabs,
  // …repeat for each component you localize
});

configure({lang: 'es'});
```

Namespace prefixes match the component name (e.g. `aikit.Header`, `aikit.MessageList`). Inspect `src/components/.../i18n/index.ts` for the exact key.

## Localized Components

22 components ship with built-in translations:

### Atoms

- `ChatDate`
- `SubmitButton`

### Molecules

- `ActionPopup`, `BaseMessage`, `FeedbackForm`, `FileDropZone`, `FileItem`, `InputContext`,
- `PromptInputFooter`, `PromptInputPanel`, `StarRating`, `Tabs`, `ToolStatus`

### Organisms

- `AttachmentPicker`, `FileUploadDialog`, `Header`, `MessageList`, `ThinkingMessage`, `ToolMessage`

### Templates

- `EmptyContainer`, `History`

### Pages

- `ChatContainer`

Components not listed above either have no visible text or take all text through props.

## See Also

- `@gravity-ui/i18n` documentation: <https://github.com/gravity-ui/i18n>
- `ChatContainer`'s aggregated `texts` prop: [src/components/pages/ChatContainer/types.ts](../src/components/pages/ChatContainer/types.ts) (`ChatContainerTexts` interface)
