Nuxt I18n
Nuxt I18n owns locale messages, localized routes, language detection, and locale metadata. Nuxt owns the surrounding page, rendering, and server lifecycle.
Workflow
- Inspect the installed
@nuxtjs/i18n version, nuxt.config.*, i18n/i18n.config.*, locale files, and affected pages. The setup is understood when locale codes, files, defaultLocale, and the routing strategy agree.
- Open the smallest matching guide below. Keep module options in
nuxt.config, Vue I18n options in i18n.config, and translated messages in locale files.
- Implement with localized links and module composables so routing, message loading, and SEO share one locale state.
- Run
nuxi prepare and the project's typecheck, then visit the affected route in the default and one secondary locale. The change is complete when both locales render the expected message, URL, language metadata, and fallback behavior.
Routing
| Task |
Open |
| Installation, locale objects, file layout, browser detection, or Vue I18n config |
Configuration |
| Translation keys, interpolation, plurals, dates, numbers, or runtime message loading |
Messages |
| Route strategies, localized links, switchers, custom paths, dynamic slugs, or SEO |
Routing and SEO |
| Nuxt pages, middleware, data fetching, SSR state, or server routes |
nuxt skill |
Baseline
npx nuxi@latest module add @nuxtjs/i18n
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
defaultLocale: 'en',
locales: [
{ code: 'en', language: 'en-US', name: 'English', file: 'en.json' },
{ code: 'fr', language: 'fr-FR', name: 'Français', file: 'fr.json' },
],
},
})
{
"welcome": "Welcome"
}
Locale files resolve from i18n/locales/ by default. Use the same locale code in configuration, route helpers, locale files, and fallback rules.
1---2name: nuxt-i18n3description: Internationalize Nuxt applications with @nuxtjs/i18n. Use when configuring locales or browser detection, translating messages or routes, building locale switchers, handling fallbacks, lazy-loading messages, or adding locale SEO.4license: MIT5---6
7# Nuxt I18n
8
9Nuxt I18n owns locale messages, localized routes, language detection, and locale metadata. Nuxt owns the surrounding page, rendering, and server lifecycle.
10
11## Workflow
12
131. Inspect the installed `@nuxtjs/i18n` version, `nuxt.config.*`, `i18n/i18n.config.*`, locale files, and affected pages. The setup is understood when locale codes, files, `defaultLocale`, and the routing strategy agree.
142. Open the smallest matching guide below. Keep module options in `nuxt.config`, Vue I18n options in `i18n.config`, and translated messages in locale files.
153. Implement with localized links and module composables so routing, message loading, and SEO share one locale state.
164. Run `nuxi prepare` and the project's typecheck, then visit the affected route in the default and one secondary locale. The change is complete when both locales render the expected message, URL, language metadata, and fallback behavior.
17
18## Routing
19
20| Task | Open |
21| ------------------------------------------------------------------------------------ | -------------------------------------------- |
22| Installation, locale objects, file layout, browser detection, or Vue I18n config | [Configuration](references/configuration.md) |
23| Translation keys, interpolation, plurals, dates, numbers, or runtime message loading | [Messages](references/messages.md) |
24| Route strategies, localized links, switchers, custom paths, dynamic slugs, or SEO | [Routing and SEO](references/routing.md) |
25| Nuxt pages, middleware, data fetching, SSR state, or server routes | `nuxt` skill |
26
27## Baseline
28
29```bash
30npx nuxi@latest module add @nuxtjs/i18n
31```
32
33```ts
34export default defineNuxtConfig({
35 modules: ['@nuxtjs/i18n'],
36 i18n: {
37 defaultLocale: 'en',
38 locales: [
39 { code: 'en', language: 'en-US', name: 'English', file: 'en.json' },
40 { code: 'fr', language: 'fr-FR', name: 'Français', file: 'fr.json' },
41 ],
42 },
43})
44```
45
46```json
47{
48 "welcome": "Welcome"
49}
50```
51
52Locale files resolve from `i18n/locales/` by default. Use the same locale code in configuration, route helpers, locale files, and fallback rules.