Im using i18n plugin in my project Nuxt 3.. and I use plugin for:
plugins/i18n.ts
export default defineNuxtPlugin(nuxtApp => {
// called right before setting a new locale
nuxtApp.hook('i18n:beforeLocaleSwitch', ({ oldLocale, newLocale, initialSetup, context }) => {
console.log('onBeforeLanguageSwitch', oldLocale, newLocale, initialSetup)
})
})
I need on my page pages/product/[slug].vue
to take this event because I need to reload data about the product (by selecting a language). Is it possible to use a plugin in a page/component? (of course, the watcher can be used to locally
, or route prefix, and more but I’m looking for a solution using a plugin)
The question is whether I understand the plugin correctly, and whether it is suitable for this use case.