i18n in modal (nuxt3)
Hi, can anyone tell me how I can add i18n support to modals in nuxt3 ? I can use i18n at the base site, but I need a scoped i18n in my modal which was working perfectly fine with the i18n module for nuxt2. How can I do this in nuxt3 ? I use the options api wrapped by defineNuxtComponent(...)
2 Replies
you might want to give a little more context and code for your issue. I don't see why handling a modal would in any way be different than any other component tbh
thats what I thought, too, but it seems to be or maybe it is a bug 😉
some more context:
my issue is with oruga modal. I'm on nuxt3 calling my modal from javascript (options api) like this:
The TestModal is very basic and I want to provide i18n functionality (also options api), but when I add
useI18n
the modal doesn't show, it just shows a black overlay. Modal:
The browser debug gives me:
I have no async setup and since I call this modal from javascript I don't have <Suspense>
tags
is this a bug ? how can I call this modal from javascript without having it pre rendered and shown by condition ?
If I use composition api like this
everything works fine, but I need the options api, switch to composition api is a no go (migrating a very huge project from nuxt2 to nuxt3 with many modals and lots of logic inside these modals)
I found the mistake...unbelievable! 😛
There seems to be a problem with the defineNuxtComponent
method as a wrapper for the options api, it mainly seems to be aimed at async data which causes my error. So instead of doing a
you can use the native vue function defineComponent
and the modal works perfectly fine...omg! 😉