Unhandled promise rejection TypeError: "this._t is undefined"

orblazer
0
orblazer
commented 2 months ago

Version

v6.1.1

Reproduction link

https://codesandbox.io/embed/codesandbox-nuxt-9x6hs

Steps to reproduce

  1. install module
  2. create an plugin with call context.app.$t

What is expected ?

This is need call translate method like context.app.i18n.t

What is actually happening?

This throw error :
Unhandled promise rejection TypeError: "this._t is undefined"

Additional comments?

In types definition the context.app.i18n is defined to option but in reality is same as https://github.com/nuxt-community/nuxt-i18n/blob/2e7f51964d94da8dfb3909193753be9d91f5d436/types/vue.d.ts#L109

bug
0
rchl
373
rchl
commented 2 months ago

It works in the codesandbox that you made, it seems.

The typescript types are not related to runtime errors and also I'm not sure what do you mean with that type that you've pointed out…

0
orblazer
0
orblazer
commented 2 months ago

I have add typescript in comments for note ;)

For code sandbox not show error, but if you open in editor the error is showed (this is strange).

0
rchl
373
rchl
commented 2 months ago

Unhandled promise rejection TypeError: "this._t is undefined" doesn't seem like an editor error. I'm confused, is it a problem with running the app in the browser or in your editor?

0
orblazer
0
orblazer
commented 2 months ago

on my project is it on my browser but on code sandbox (appear in browser console too).

That is stack trace from console in code sandbox :

Unhandled promise rejection t@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:6498:3
 defaultMessage@https://9x6hs.sse.codesandbox.io/_nuxt/app.js:5020:20
 _normalizeMessage@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:3581:16
 _generateFieldError@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:3575:14
 _test/</<@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:3557:58
 step@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:2985:23
 verb/<@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:2966:53
 fulfilled@https://9x6hs.sse.codesandbox.io/_nuxt/vendors.app.js:2956:58
 run@https://9x6hs.sse.codesandbox.io/_nuxt/commons.app.js:3262:22
 notify/<@https://9x6hs.sse.codesandbox.io/_nuxt/commons.app.js:3279:30
 flush@https://9x6hs.sse.codesandbox.io/_nuxt/commons.app.js:1796:9
0
rchl
373
rchl
commented 2 months ago

Right, I can reproduce that. Seems to be happening when using @/plugins/vee-validate plugin and it's probably more related to vue-i18n then this module.

Could be related: https://github.com/kazupon/vue-i18n/issues/184

0
orblazer
0
orblazer
commented 2 months ago

Ok, thanks, I didn't think to look on vue-i18n

0
rchl
373
rchl
commented 2 months ago

Actually app.$t() has no chance of working, it needs to be called on VueI18n instance, so this should work instead app.i18n.t() (notice no $ here).

I'm removing app.$t. I don't believe it ever worked.

0
rchl
373
rchl
commented 2 months ago

I've removed app.$t in ca198e5ad8b71329e095811f09076aa5bb91f768.

0
Informations
Bug ReportOpen
#c296 - Created 2 months ago