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

jovanmaric
0
jovanmaric
commented 3 months ago

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.

bug
0
jovanmaric
0
jovanmaric
commented 3 months ago

On second inspection, it seems that enabling @kazupon/vue-i18n-loader makes this.$i18n unreadable.

Edit:
I can access the locales with:
console.log(this.$parent.$i18n.locales);

0
iliyaZelenko
0
iliyaZelenko
commented 2 months ago

@jovanmaric, I watched your code and library code, it's hard to say why this happens, try asking a question in their repository.

0
sambrezo
0
sambrezo
commented a month ago

The same problem occurs when using Component based localization with vue-i18n. I don't think it's related to YAML.

0
sambrezo
0
sambrezo
commented 13 days ago

I just came back to this issue and this time it works. I could be totally off here, but in my code I am no longer using the locales.name property for the lang-switcher.

0
jovanmaric
0
jovanmaric
commented 7 days ago

I'm unable to test this unfortunately, as I switched to app wide localization, to improve reusability. This issue can be closed as both @iliyaZelenko and @sambrezo are referring to the vue-i18n as the major culprit.

Edit: Hope github delegates the closing of an issue to cmty…… it does

0
Informations
Bug ReportOpen
#c195 - Created 3 months ago