Setup nuxt/i18n v7 module.
Add @nuxtjs/i18n
dependency to your project:
yarn add @nuxtjs/i18n@7x
Then, add @nuxtjs/i18n
to the modules
section in your nuxt.config.js
. You can use either of the following ways to specify the module options:
{
modules: [
'@nuxtjs/i18n',
],
i18n: {
/* module options */
},
}
or
{
modules: [
[
'@nuxtjs/i18n',
{ /* module options */ }
]
],
}
The former approach has the benefit of having type-checking enabled if you have followed the Typescript setup.
If using typescript or running typescript language server to check the code (for example through Vetur), add types to types
array in your tsconfig.json
:
{
"compilerOptions": {
"types": ["@nuxt/types", "@nuxtjs/i18n"]
}
}