i18n icon indicating copy to clipboard operation
i18n copied to clipboard

allow configuration from `app.config.ts` and extending `(@nuxt/schema).AppConfig`

Open kazupon opened this issue 2 years ago • 5 comments

          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

kazupon avatar Apr 12 '23 14:04 kazupon

I would try my hand at this

TitusKirch avatar Aug 01 '23 17:08 TitusKirch

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?

TitusKirch avatar Aug 01 '23 19:08 TitusKirch

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 avatar Aug 01 '23 19:08 ineshbose

@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 avatar Aug 01 '23 19:08 TitusKirch

@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.

kazupon avatar Aug 02 '23 01:08 kazupon