intlify / nuxt3

Nuxt 3 Module for vue-i18n-next

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Not working `vueI18n.locale` options

dungsil opened this issue · comments

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.

@dungsil seems you are missing vueI18n.locales with translations

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

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

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

nuxt3/README.md

Lines 67 to 85 in 2df57f6

export default {
// ...
buildModules: ['@intlify/nuxt3'],
// config for `@intlify/nuxt3`
intlify: {
vueI18n: {
// You can setting same `createI18n` options here !
locale: 'en',
messages: {
en: {
hello: 'Hello'
},
ja: {
hello: 'こんにちは'
}
}
}
}
}

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

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

const i18n = createI18n({
legacy: false,
globalInjection: true,
locale: 'en',
...loadedOptions
})

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.

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',
    }
  }
})