# General Translation React SDKs (gt-react, gt-next, gt-react-native): loadDictionary
URL: https://generaltranslation.com/en-US/docs/react/reference/functions/load-dictionary.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Load your own dictionary translations as a standalone i18n library. API reference for loadDictionary.

`loadDictionary` is a loader function you define to load a dictionary of translations for a locale. It is intended for using `gt-react` as a standalone i18n library — for bringing your own translations, typically when migrating an existing i18n project to General Translation.

*Applies to `gt-react`, `gt-next`, `gt-tanstack-start`, and `gt-react-native`, but the wiring differs. `loadDictionary` is a loader you define, not an exported symbol. In `gt-react` and `gt-tanstack-start`, pass it to the initialization call (below); `gt-next` resolves it through the `withGTConfig` plugin (documented in the Next.js section). The loader contract on this page is the same everywhere.*

## Overview [#overview]

Define a function that takes a locale and returns its dictionary, then pass it as the `loadDictionary` option to [`initializeGT`](/docs/react/reference/config#initialize). Single-page apps pass it to [`initializeGTSPA`](/docs/react/reference/config#initialize-spa) instead.

```tsx
const loadDictionary = (locale: string) =>
  import(`../public/locales/${locale}.json`).then((m) => m.default);

initializeGT({ ...gtConfig, loadDictionary });
```

*Note: in `gt-react`, `loadDictionary` is a configuration option on the initialization call, not a prop on [`<GTProvider>`](/docs/react/reference/components/gt-provider). `loadDictionary` only supports JSON files with string translations.*

## How it works [#how-it-works]

- **Standalone translations.** `loadDictionary` loads a translation JSON file for a given locale. Use it when you bring your own translations and do not rely on General Translation's translation infrastructure.
- **Precedence.** When multiple translations exist, dictionaries loaded by `loadDictionary` always take precedence over translations loaded by [`loadTranslations`](/docs/react/reference/functions/load-translations).
- **JSON only.** It supports only JSON files containing string translations.

*The difference between the two loaders: [`loadTranslations`](/docs/react/reference/functions/load-translations) customizes fetching machine-generated translations managed by the CLI (from a CDN, database, or bundle), while `loadDictionary` is for implementing `gt-react` as a standalone library with your own translations and no translation infrastructure.*

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`locale`](#locale) | The locale to load translations for. | `string` | No | — |

### `locale` [#locale]

**Type** `string` · **Required**

The locale for which the dictionary should be loaded.

## Returns [#returns]

**Type** `Promise<Dictionary>`

A promise resolving to a `Dictionary` mapping ids to translations for the given locale.

## Examples [#examples]

```js title="loadDictionary.js"
export default async function loadDictionary(locale) {
  const translations = await import(`../public/locales/${locale}.json`);
  return translations.default;
}
```

## Notes [#notes]

- `loadDictionary` loads your own translations for standalone use, and takes precedence over [`loadTranslations`](/docs/react/reference/functions/load-translations).
- It supports only JSON files with string translations.
- Resolve dictionary entries at runtime with [`useTranslations`](/docs/react/reference/hooks/use-translations).

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
