i18n: Error parsing "nuxtI18n" component option in file

Version

nuxt: 2.14.7 nuxt-i18n: 6.15.3

nuxt.config.js

{
 buildModules: [
    '@nuxt/typescript-build',
    '@nuxtjs/vuetify',
    ['nuxt-i18n', {
      lazy: true,
      langDir: 'lang/',
      defaultLocale: 'ru',
      locales: [
        { code: 'ru', file: 'ru.ts' },
        { code: 'en', file: 'en.ts' }
      ]
    }]
  ]
}

At the beginning of the assembly, it issues such warnings, and not on all pages.

image

Could this cause problems?

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 3
  • Comments: 20 (1 by maintainers)

Most upvoted comments

Still experiencing this issue. In my case, it happens if I use any external variable/import in the nuxtI18n component options. E.g. this works:

@Component({
  nuxtI18n: {
    locales: ['en'],
  },
})

while the code below triggers the error and does not let nuxtI18n apply the in-component options for the page.

const myLocales = ['en'];

@Component({
  nuxtI18n: {
    locales: myLocales,
  },
})

I was not able to overcome this issue, it’s a huge blocker

Edit: This issue is nastier than I thought. I get the issue even if I try to specify some TS typings. E.g.:

@Component({
  nuxtI18n: {
    locales: ['en'] as Array<string>,
  },
})

Thank you @Luferov for the reply. I’m running a Vue2 application, its possible to implement your suggestion with a plugin like this Composition API plugin for Vue 2 ?

If possible, would you mind providing us an example? Thank you again in advance!

Of course, no problem. We are writing an application and it is open source. We are currently transitioning to nuxt3 and therefore are now in the nuxt-bridge version. For example, https://github.com/devind-team/dcis/tree/main/client.

I would advise you to use the composition API instead of the basic class style from your project. And this error will go away.