# loadLocale

Lazy-load the built-in translation pack for a locale

## Import

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

`loadLocale` imports the built-in pack for a tag, or for the closest tag in its [`findLocaleKeys`](https://videojs.org/docs/framework/react/reference/api/find-locale-keys) chain, and resolves to its flat translations. It resolves to `undefined` when that chain reaches a locale registered with [`registerI18n`](https://videojs.org/docs/framework/react/reference/api/register-i18n) first, or when no built-in pack matches. Providers call it for you; use it to translate UI outside a provider without bundling every pack.

```ts
import { createTranslator, getI18nTranslations, loadLocale } from '@videojs/react/i18n';

const pack = await loadLocale('fr-CA');
const t = createTranslator({ ...pack, ...getI18nTranslations('fr-CA') }, 'fr-CA');

t('buttons.play'); // 'Lecture'
```

## API Reference

`loadLocale(tag): Promise<Partial<FlatTranslations> | undefined>`

### Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `tag` (required) | `string` | — | BCP 47 tag to load, such as `fr-CA`. |

### Return Value

| Type |
| --- |
| `Promise<Partial<FlatTranslations> \| undefined>` |

---

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