Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

'/nuxt-i18n/options.js' does not provide an export named 'localeMessages' #156

Open
flozero opened this issue Jun 18, 2021 · 4 comments · Fixed by nuxt-modules/i18n#1251
Labels
bug Something isn't working

Comments

@flozero
Copy link

flozero commented Jun 18, 2021

Versions

nuxt-vite: 0.1.1
nuxt: 2.15.7

Reproduction

  • Install nuxt with nuxt-18n
  • Non-existent export 'localeMessages' is imported from resources/assets/js/.nuxt/nuxt-i18n/options.js

Description

Screen Shot 2021-06-18 at 7 00 11 PM

@rchl
Copy link

rchl commented Jun 19, 2021

I'm not sure why is that but just gonna add this extra screenshot:

Screenshot 2021-06-19 at 22 59 56

@pi0 any extra considerations that have to be taken into account when using addTemplate / addPlugin?

@romainmartinez
Copy link

I also get this issue with:

nuxt: 2.15.3
nuxt-vite: 0.1.1
nuxt-i18n: 6.27.1

@jolc
Copy link

jolc commented Aug 1, 2021

Use langDir + translation files seems to eliminate the error.

  // nuxt.config.js
  i18n: {
    locales: 
      [{
        code: 'zh',
        file: 'zh-HK.js'
      }, {
        code: 'en',
        file: 'en-GB.js'
      }],
    defaultLocale: 'zh',
    langDir: 'lang/', // <---
    vueI18n: {
      fallbackLocale: 'zh',
    }
  },
// lang/en-GB.js
export default {
  welcome: 'Welcome'
}
// package.json
"nuxt": "^2.15.7",
"nuxt-vite": "^0.1.0",
"nuxt-i18n": "^6.27.2",

It looks like the plugin checks for langDir before exporting localeMessages in options.js

// node_modules/nuxt-i18n/src/templates/options.js
if (langDir) { %>
export const localeMessages = {
...

See documentation for landDir option and translation files
https://i18n.nuxtjs.org/options-reference#langdir
https://i18n.nuxtjs.org/lazy-load-translations/

@rchl
Copy link

rchl commented Aug 2, 2021

Thanks for that. So it's actually an issue with nuxt-i18n. Fixing in nuxt-modules/i18n#1251.

rchl added a commit to nuxt-modules/i18n that referenced this issue Aug 2, 2021
The import needs to be provided since it's imported unconditionally.

Fixes nuxt/vite#156
rchl added a commit to nuxt-modules/i18n that referenced this issue Aug 2, 2021
The import needs to be provided since it's imported unconditionally.

Fixes nuxt/vite#156
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants