# vue: LoadTranslations URL: https://generaltranslation.com/en-GB/docs/vue/reference/types/load-translations.mdx --- title: LoadTranslations description: Load the complete translation catalogue for a requested locale. API reference for LoadTranslations. --- Provide this callback to [`createGT()`](/docs/vue/reference/functions/create-gt) or [`initializeGTSPA()`](/docs/vue/reference/functions/initialize-gt-spa) when target catalogues are stored in application files, a database, an API, or another host. ## Overview [#overview] ```ts type LoadTranslations = ( locale: string ) => Promise; ``` The plugin calls the loader only for uncached target locales. The default locale uses the source text and never calls it. ## Parameters [#parameters] | Parameter | Description | Type | Optional | Default | | --------- | --------------------------------------------------- | -------- | -------- | ------- | | `locale` | Locale whose complete catalogue should be returned. | `string` | No | — | A standard [`createGT()`](/docs/vue/reference/functions/create-gt) plugin passes the requested locale unchanged. An [`initializeGTSPA()`](/docs/vue/reference/functions/initialize-gt-spa) plugin first resolves the locale against its configured `locales` and `customMapping`, preserving the configured spelling for file paths. ## Return value [#returns] **Type** `Promise<`[`TranslationCatalog`](/docs/vue/reference/types/translation-catalog)`>` Resolve with the complete hash-keyed catalogue for `locale`. Resolve with `{}` when no translations are available and the application should use source content. Do not return `null`, `undefined`, or a partial value with a different shape. The public callback type requires a catalogue object. ## Loading behaviour [#loading-behavior] * A successful result is cached for the lifetime of that plugin. * Concurrent loads for the same locale share one promise. * `plugin.loadTranslations(locale)` preloads without changing the active locale. * A reactive `plugin.setLocale(locale)` loads before switching. * [`initializeGTSPA()`](/docs/vue/reference/functions/initialize-gt-spa) loads the initial target locale before its promise resolves. * Installing a [`createGT()`](/docs/vue/reference/functions/create-gt) plugin starts the initial target load in the background, allowing source content to render first. ## Failures [#failures] When the callback rejects, `gt-vue` logs a diagnostic, rethrows the same failure, removes the in-flight entry, and leaves the result uncached. A later call can retry. An imperative `loadTranslations()` call, a reactive locale change, or SPA initialisation therefore rejects. The background load started by `app.use(createGT(...))` catches the rejection after logging, allowing the application to continue with source content. ## Example [#example] ```ts title="src/loadTranslations.ts" import type { LoadTranslations } from 'gt-vue'; const loadTranslations: LoadTranslations = async (locale) => { try { return (await import(`./_gt/${locale}.json`)).default; } catch (error) { console.error(`No translation catalog for ${locale}`, error); return {}; } }; export default loadTranslations; ``` The loader above converts missing files into a successful empty catalogue. Remove the `try`/`catch` if a missing or invalid catalogue should prevent initialisation.