#How to make internalization languages in NuxtJS 3?
3 messages · Page 1 of 1 (latest)
Hi @ashen granite. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, it is possible to implement internationalization (i18n) in Nuxt 3. Nuxt 3 has official support for internationalization through the @nuxtjs/i18n module. Here's a brief overview of how to set it up:
-
Install the @nuxtjs/i18n module in your Nuxt 3 project.
-
Configure the module in your
nuxt.config.tsfile:
export default defineNuxtConfig({
modules: ['@nuxtjs/i18n'],
i18n: {
vueI18n: './i18n.config.ts'
}
})
- Create an
i18n.config.tsfile in your project root to define your locales and translations:
export default defineI18nConfig(() => ({
legacy: false,
locale: 'en',
messages: {
en: {
welcome: "Welcome"
},
fr: {
welcome: "Bienvenue"
}
}
}))
- Use the translations in your Vue components:
<template>
<p>{{ $t('welcome') }}</p>
</template>
<script setup>
const { locale, setLocale } = useI18n()
</script>
This setup allows you to easily manage multiple languages in your Nuxt 3 application.