question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this.$i18n.locales is undefined when using yaml-loader

See original GitHub issue

Version

v5.3.0

Reproduction link

https://github.com/jovanmaric/nuxti18n-yaml

Steps to reproduce

  • Start with yarn dev.
  • Open console to see this.$i18n.locales outputting an array
  • Stop server
  • Uncomment the build configuration in nuxt.config.js
  • Start with yarn dev
  • Open console to see undefined

What is expected ?

That this.$i18n.locales returns the locales array even when using <i18n> component tags.

What is actually happening?

It seems like either vue-i18n-loader or yaml-loader are polluting the this.$i18n namespace

Additional comments?

I’ve looked at the src, but im not sure how to fix this without side effects. this.i18n seems to be where Vue-i18n is bound to by default, and nuxt-i18n extends on this behaviour.

<div align="right">This bug report is available on Nuxt community (#c195)</div>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

3reactions
arambertcommented, Jun 5, 2019

As a temporary workaround I add these lines in a beforeMount function in the components where I need locales or switchLocalePath:

this.$i18n['differentDomains'] = this.$root.$i18n['differentDomains']
this.$i18n['locales'] = this.$root.$i18n['locales']
2reactions
arambertcommented, Jun 5, 2019

I’m facing the same issue:

It does not matter if it’s YAML or JSON.

I don’t know if this bug should be nuxt-i18n responsability or vue-i18n responsability, but there is a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

this.$i18n.locales is undefined when using yaml-loader #205
Start with yarn dev . Open console to see this.$i18n.locales outputting an array; Stop server; Uncomment the build configuration in nuxt.config.
Read more >
nuxt-i18n: Lang Switcher Error "Object is possibly 'undefined'
I want to build a language switcher on my nuxt app with nuxt-i18n plugin. Important note is, that ...
Read more >
Single file components | Vue I18n
If you are building Vue component or Vue application using single file components, you can manage the locale messages i18n custom block.
Read more >
mini-i18n-extract-plugin - npm
Start using mini-i18n-extract-plugin in your project by running `npm ... To extract i18n files and split them by locales, add the loader and ......
Read more >
cannot read properties of undefined (reading 'data') axios
I need to post some form data to a mockapi endpoint, using Axios and Vuex. I'm using Vue Cli v2, and Vuex 3....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found