allow configuration from `app.config.ts` and extending `(@nuxt/schema).AppConfig`
Minor future task: allow configuration from `app.config.ts` and extending `(@nuxt/schema).AppConfig`
Originally posted by @ineshbose in https://github.com/nuxt-modules/i18n/issues/1973#issuecomment-1503040092
I would try my hand at this
Just to discuss the scope of it:
It is desired, instead of the file i18n.config.ts with the content
export default defineI18nConfig(() => ({
legacy: false,
locale: 'en',
messages: {
fr: {
welcome: 'Bienvenue',
home: 'Accueil',
profile: 'Profil'
},
en: {
welcome: 'Welcome',
home: 'Homepage',
profile: 'Profile'
}
}
}))
to be able to use the file app.config.ts with the content
export default defineAppConfig({
i18n: {
vueI18n: {
legacy: false,
locale: 'en',
messages: {
fr: {
welcome: 'Bienvenue',
home: 'Accueil',
profile: 'Profil'
},
en: {
welcome: 'Welcome',
home: 'Homepage',
profile: 'Profile'
}
}
}
}
})
Or have I overlooked something?
That's about right, because app.config.ts is runtime logic (if I'm not wrong).
We can probably flatten i18n.vueI18n to i18n. Somethings to look out for - in cases, where i18n.config.ts is available, either we likely prefer that, or we merge both configs using defu (preferred). If we're able to implement defu with this, we can allow configuration to be highly extensible (more plans on this).
@ineshbose thanks for your quick answer!
I could pack i18n.vueI18n directly into i18n, I just wanted to get some input on this first (especially with regard to other things that might be planned in the future). Exactly, I have already used defu in the first version, as this is also my preferred implementation.
@TitusKirch Thank you for your contribution! I recognize about nuxt i18n has issue, as I have heard from others (@kiaking) that it should be flat.
nuxt i18n v8 rc was realsed 2 days ago. This means that breaking changes to the interface will not occur until v8 official releases.
We should work this issue in nuxt i18n v9.