# General Translation React SDKs (gt-react, gt-next, gt-react-native): loadDictionary
URL: https://generaltranslation.com/en-GB/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 use with `gt-react` as a standalone i18n library — to bring 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 initialisation 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 initialisation 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 JSON translation file for a given locale. Use it when you bring your own translations and do not rely on General Translation&#39;s translation infrastructure.
* **Precedence.** When multiple translations exist, dictionaries loaded by `loadDictionary` always take precedence over those 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) customises fetching machine-generated translations managed by the CLI (from a CDN, database, or bundle), while `loadDictionary` is used to implement `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 that resolves 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.
