# I18nProvider

React provider that resolves locale and supplies a typed translator to descendants

## Import

```tsx
import { I18nProvider } from "@videojs/react";
```

`I18nProvider` resolves the active locale, lazy-loads built-in packs, merges registry and provider layers, and exposes a translator through context. Wrap it around a player or custom controls that should translate.

Wrap custom controls or force a locale explicitly:

```tsx
import { I18nProvider } from '@videojs/react/i18n';

<I18nProvider locale="de" translations={{ buttons: { play: 'Abspielen' } }}>
  <MyControls />
</I18nProvider>
```

Omit `locale` to inherit the nearest `lang` attribute (via `langRootRef` or `<html lang>`). English is the fallback when no non-English locale is active or no translation layer supplies a string. See [Internationalize the player](https://videojs.org/docs/framework/react/guides/internationalization) for merge priority, browser translation fallback, and SSR guidance.

`translations` takes a partial `Translations` map in the nested shape described in [Translation phrases](https://videojs.org/docs/framework/react/reference/api/translation-phrases). `onActiveLocaleChange` receives the resolved `Locale` tag.

The provider supplies its translator and locale through `I18nContext`. Read them with [`useTranslator`](https://videojs.org/docs/framework/react/reference/api/use-translator) and [`useLocale`](https://videojs.org/docs/framework/react/reference/api/use-locale), which fall back to English outside a provider. Read `I18nContext` with `useContext` only when a component needs to know whether a provider is mounted: its value is `null` without one.

## API Reference

`I18nProvider(props): ReactNode`

### Parameters

| Parameter | Type | Default |
| --- | --- | --- |
| `props` (required) | `{ locale?: (typeof LOCALES)[number] \| string & {}; langRootRef?: RefObject<Element \| null>; translations?: Partial<Translations>; children: ReactNode; onActiveLocaleChange?: ((locale: Locale) => void) }` | — |

### Return Value

`ReactNode`

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
