Setup
❗IMPORTANT
- From this section, this documentation is for Nuxt i18n module (
@nuxtjs/i18n
) v8 beta. If you would like to use v7.x, see here. - Nuxt i18n module's next version, v8, is in beta and still undergoing development. Its API may be subject to changes that could cause compatibility issues. Although the development team will try to maintain the same interface as version 7.x, the upcoming major release of Nuxt 3 may introduce changes that could affect the interface.
Check the Nuxt documentation for more information about installing and using modules in Nuxt.
Add @nuxtjs/i18n
dependency to your project:
NPM
npm install @nuxtjs/i18n@next --save-dev
package.json
Then, you need to add "type": "module"
to package.json
of your nuxt project.
This is necessary because nitro prerender is used for the dynamic import of nuxt i18n config and i18n resources on the Node runtime, on nuxt build.
nuxt.config.ts
Then, add @nuxtjs/i18n
to the modules
section in your nuxt.config
. You can use either of the following ways to specify the module options:
nuxt.config.ts
export default defineNuxtConfig({
modules: [
'@nuxtjs/i18n',
],
i18n: {
/* module options */
}
})
or
nuxt.config.ts
export default defineNuxtConfig({
modules: [
[
'@nuxtjs/i18n',
{ /* module options */ }
]
]
})
Table of Contents