How to use localePath() in middleware
max5432112345 opened this issue · comments
export default defineNuxtRouteMiddleware((to, from) => {
const nuxtApp = useNuxtApp()
const locales = nuxtApp.vueApp.i18n.availableLocales // locales localeCodes
const isLocalised = locales.some(locale => to.fullPath.startsWith('/' + locale))
if (!isLocalised) {
return navigateTo(localePath(to))
}
}
or how to get fallback locale?