# vue: Quickstart
URL: https://generaltranslation.com/en-GB/docs/vue/quickstart.mdx
---
title: Quickstart
description: Add multiple languages to a Vue application with General Translation in under 10 minutes.
related:
links:
- /docs/vue/guides/translating-content
- /docs/vue/guides/translating-strings
- /docs/vue/guides/managing-locales
- /docs/vue/guides/storing-translations
---
By the end of this guide, your Vue app will display content in multiple languages and allow users to change the active locale without reloading the page.
`gt-vue` runs as a Vue plugin. The plugin loads each translation catalogue once, caches it, and reactively rerenders translated content when the locale changes.
**Prerequisites:**
* A Vue 3 application running version 3.3 or later
* Node.js 18+
## Quickstart [#quickstart]
### 1. Install the packages
`gt-vue` powers translations in your app. [`gt`](/docs/cli/quickstart) extracts your source content and generates translation catalogues.
```bash
npm install gt-vue
npm install --save-dev gt
```
```bash
yarn add gt-vue
yarn add --dev gt
```
```bash
bun add gt-vue
bun add --dev gt
```
```bash
pnpm add gt-vue
pnpm add --save-dev gt
```
### 2. Create a translation config file
Create `gt.config.json` in your project root. Set the locale of your source content, the locales to translate into, and the output path for generated catalogues.
```json title="gt.config.json"
{
"defaultLocale": "en",
"locales": ["es", "fr", "ja"],
"files": {
"gt": {
"output": "src/_gt/[locale].json"
}
}
}
```
* `defaultLocale` is the language of your source content.
* `locales` lists the target languages. Choose any locale from the [supported locales list](/docs/platform/dashboard/reference/supported-locales).
* `files.gt.output` tells the CLI where to write each catalogue. Keep the `[locale]` placeholder in the path.
### 3. Create a translation loader
Create a loader that returns the generated catalogue for the requested locale:
```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 {
return {};
}
};
export default loadTranslations;
```
The loader is not called for the default locale because your source content already serves as its catalogue. Returning an empty object lets the app render source content when a target catalogue is unavailable.
### 4. Register the plugin
Create a [`createGT()`](/docs/vue/reference/functions/create-gt) plugin and install it before mounting your app:
```ts title="src/main.ts"
import { createApp } from 'vue';
import { createGT } from 'gt-vue';
import App from './App.vue';
import gtConfig from '../gt.config.json';
import loadTranslations from './loadTranslations';
const gt = createGT({
defaultLocale: gtConfig.defaultLocale,
loadTranslations,
});
createApp(App).use(gt).mount('#app');
```
The plugin uses the saved locale cookie when available; otherwise, it starts with `defaultLocale`. It mounts immediately with source content, then updates reactively when the requested catalogue finishes loading.
### 5. Mark content for translation
Use [``](/docs/vue/reference/components/t) for rich template content and [`useGT()`](/docs/vue/reference/composables/use-gt) for standalone strings, such as input attributes:
```vue title="src/App.vue"
Welcome to my app
This content will be translated automatically.
```
Keep content inside [``](/docs/vue/reference/components/t) static. Use [variable and branching components](/docs/vue/guides/formatting-variables) for runtime values and conditional alternatives.
### 6. Add a language switcher
Read the current locale with [`useLocale()`](/docs/vue/reference/composables/use-locale) and change it with [`useSetLocale()`](/docs/vue/reference/composables/use-set-locale):
```vue title="src/App.vue"
Welcome to my app
This content will be translated automatically.
```
[`useSetLocale()`](/docs/vue/reference/composables/use-set-locale) loads a missing catalogue before saving the locale cookie and re-rendering reactive consumers. With the loader above, a missing file returns an empty catalogue, changes the locale and renders source content. If a loader rejects instead, the current locale remains active.
### 7. Authenticate and translate
Authenticate with General Translation:
```bash
npx gt auth
```
The command guides you through signing in and creating credentials. Keep the generated production API key in your local environment file and out of browser code and version control.
Then generate the translation catalogues:
```bash
npx gt translate
```
The CLI scans your Vue source, translates the extracted content, and writes one JSON file per target locale to `src/_gt/`. Run the command again whenever your source content changes.
## Troubleshooting [#troubleshooting]
The active locale is stored in the `generaltranslation.locale` cookie. Clear any stale cookie, then select the target locale again. Also confirm that its JSON file exists under `src/_gt/` and that the loader returns its default export.
Call the function returned by [`useGT()`](/docs/vue/reference/composables/use-gt) from the template or a Vue computed value. A string translated once during setup is a snapshot and does not run again when reactive locale state changes.
## Next steps
- /docs/vue/guides/translating-content
- /docs/vue/guides/translating-strings
- /docs/vue/guides/managing-locales
- /docs/vue/guides/storing-translations