I'm working with nuxt 3, is there any way in which I can automatically set options for a module?
I want to fetch the active locales and the default locale I set up in Strapi, and automatically set those in the i18n module.
export default defineNuxtConfig({
modules: [
'@nuxtjs/i18n',
'@nuxtjs/strapi'
],
i18n: {
strategy: 'prefix_except_default',
locales: [ // locales would be fetched from Strapi endpoint
{
code: 'en',
file: 'en.json'
},
{
code: 'it',
file: 'it.json'
},
],
langDir: 'assets/i18n',
defaultLocale: 'en', // default locale would be fetched from Strapi endpoint
},
})
I tried to import them with a plugin, but I can't sort it out, I guess there are better methods to do what I need to do
You can combine i18n plugin with pinia store.
stores/index.jsplugins/i18n.tssampleComponent.vue: