intlify / nuxt3

Nuxt 3 Module for vue-i18n-next
MIT License
201 stars 19 forks source link

[Bug] Not working `vueI18n.locale` options #48

Open dungsil opened 2 years ago

dungsil commented 2 years ago

Project info:

------------------------------
- Operating System: `Windows_NT`
- Node Version:     `v17.7.2`
- Nuxt Version:     `3.0.0-27460489.53fbca7`
- Package Manager:  `pnpm@6.32.2`
- Builder:          `vite`
- User Config:      `buildModules`, `intlify`
- Runtime Modules:  `-`
- Build Modules:    `@intlify/nuxt3@0.1.10`
------------------------------

Config:


// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
  buildModules: ['@intlify/nuxt3'],
  intlify: {
    vueI18n: {
      localeDir: 'locales',
      vueI18n: {
        locale: 'en-US',
        fallbackLocale: 'en-US',
      }
    }
  }
})

Console log: [intlify] Not found 'meta.title' key in 'en' locale messages.

razbakov commented 2 years ago

@dungsil seems you are missing vueI18n.locales with translations

dungsil commented 2 years ago

@razbakov The file locales/en-US.yml exists.

razbakov commented 2 years ago

@dungsil what's the content of that file? Does it have key "meta.title"? Try to rename that file to en.yml

dungsil commented 2 years ago

@razbakov If I do that, it works, but not i want that's solution. In the README it is marked as mutable and I want this config to work.

https://github.com/intlify/nuxt3/blob/2df57f672135fdc9bea0f7d11234e1b064e1f666/README.md?plain=1#L67-L85

razbakov commented 2 years ago

@dungsil Concerning en-US.yml and en.yml check languages of your browser. I guess i18n module takes the preferred language of your browser.

Please elaborate on your last question. I don't understand the problem. I thought your initial question was about error [intlify] Not found 'meta.title' key in 'en' locale messages..

How is mutable connected to that context?

dungsil commented 2 years ago

@razbakov

A value of ko or ko-KR must be used to work as the browser's default locale. (in my case)

My guess is that this value is probably used as is, not overwritten.

https://github.com/intlify/nuxt3/blob/2df57f672135fdc9bea0f7d11234e1b064e1f666/packages/nuxt3/src/runtime/plugin.ts#L26-L31

dungsil commented 2 years ago

I am submitting an issue in the nature of a bug report and not a question.

As the title suggests, the vueI18n.locale option does not work.

Djules commented 2 years ago

The option key localeDir should be outside vueI18n, at the root of intlifyactually.

export default defineNuxtConfig({
  buildModules: ['@intlify/nuxt3'],
  intlify: {
    localeDir: 'locales',
    vueI18n: {
      locale: 'en-US',
      fallbackLocale: 'en-US',
    }
  }
})