Compatibility with nuxt-i18n
The problem
nuxt-i18n creates an augmented VueI18n instance in this.$root.$i18n and expects vue-i18n to use it as value in _i18n (https://github.com/kazupon/vue-i18n/blob/d28e3b25d9bd9eac51fc3714a4a2940772d85c3d/src/mixin.js#L69)
But when one uses custom i18n blocks in the component with vue-i18n-loader, it fills this.$options.__i18n in the component which is picked up by https://github.com/kazupon/vue-i18n/blob/master/src/mixin.js#L9 and the this.$root.$i18n instance is never set in this._i18n.
The consequence is that this.$i18n in the component is a new basic VueI18n instance and not the nuxt-i18n augmented VueI18n instance. Such attributes as "locales" or "differentDomains" are therefore not accessible from the component and the nuxt-i18n method "switchLocalePath" is broken when using differentDomains with nuxt-i18n.
Here is the link to the comment I posted in the nuxt-i18n project: https://github.com/nuxt-community/nuxt-i18n/issues/205#issuecomment-498763751.
Suggested solution
vue-i18n-loader could use an explicit key instead of the cryptic __i18n, like _i18n_translations for instance. Then vue-i18n would handle the key specifically when present (independently from the different scenarii for setting up this._i18n), as opposed to seed option.i18n with __i18n
What are your thoughts on this?
I just ran into this issue, also (not being able to access this.$i18n.locales.
This should be fixed in nuxt-i18n. It uses a hook provided by vue-i18n the extend the local vue-i18n instance.
I'd say this is fixed in nuxt-i18n already.
close in-activity