v8
documentation compatible with Nuxt 3. @nuxtjs/i18n
as a dev dependency to your project:npx nuxi@latest module add i18n
@nuxtjs/i18n
to your nuxt.config
modules:export default defineNuxtConfig({
modules: ['@nuxtjs/i18n']
})
You can set the module options by using the i18n
property in nuxt.config
root.
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
// Module Options
}
})
Alternatively, You can pass an array of the module name and the options object to modules
export default defineNuxtConfig({
modules: [
[
'@nuxtjs/i18n',
{
// Module Options
}
]
]
})
You can opt in to the latest commits on the main
branch to avoid waiting for the next release and helping the module by beta testing changes.
Update @nuxtjs/i18n
dependency in your package.json
:
{
"devDependencies": {
- "@nuxtjs/i18n": "^8.0.0"
+ "@nuxtjs/i18n": "npm:@nuxtjs/i18n-edge"
}
}
Then remove your lockfile and reinstall the dependencies.
Update @nuxtjs/i18n
dependency in your package.json
:
{
"devDependencies": {
- "@nuxtjs/i18n": "npm:@nuxtjs/i18n-edge"
+ "@nuxtjs/i18n": "^8.0.0"
}
}
Then remove your lockfile and reinstall the dependencies.
defineI18nRoute
defineI18nRoute() is a compiler macro that you can use to set custom route paths for your page components located in the pages/ directory (unless set otherwise). This way you can set custom route paths for each static or dynamic route of your Nuxt application.
Usage
The basics to get started with the Nuxt i18n module is to translate with Vue I18n via the `vueI18n` option.